You can't use document.write after the page has loaded, because the document is closed for writing.
mrhoo's suggestion is the correct way of solving this, e.g.
- var code = "<style>#content{background-image:url(/images/" + name + ".jpg);background-repeat:repeat-y;background-position:right;background-attachment:fixed;</style>";
becomes
- var content = document.getElementById("content");
-
content.style.backgroundImage = "url(/images/" + name + ".jpg);";
-
content.style.backgroundRepeat = "repeat-y";
-
// background-position = style.backgroundPosition, background-attachment = style.backgroundAttachment