That's just an example to show you how to hide show DIV in javascript.
But it is not working in your code because you are setting DIV visible = "false" from code.
When you do that the control does not appear in HTML and hence javascript cannot find it
Instead of setting visible = "false" set the following to hide DIV
div1.Attributes["style"] = "display:none"