Why wasnt I here sooner? I saw the prob in 5 seconds. Sorry!
PS. Try that in php! <g>

No language I know of lets you mix quotes like that without escaping them, and error 2 is, even if you did escape the inners, you are asking for a string containing +id+
A simple alert(div) should have produced an error. Course, you have to know what to look for.
div.hasChildNodes() is not a function!

Why isnt it a function? Probably because div doesnt exist.

Yeah JS is a bitch, and Firebug is the ****!

I takes a whule to believe this, but when you do you will be a master Javascrip Jedi as well as a master glow Jedi.

But keep in mind, strings are contained in matching pairs of quotes
so
var div = "document.getElementById("+id+")";

that makes div a string of the object you want.
Had you done div=eval(div); it would have worked, but your "ray of Light" was definately the correct way.