Here's another angle you might try. When the HTML parser hits '</script>' in the second document.write statement, it stops the currently running script. You could test this by writing the second statment as:

document.write('</' + 'script>');

--but you may still have problems because of the nested script tags.

If all else fails, load the page in Netscape and see what their javascript console has to say (type javascript: in the location window).