As described in the Tech Tip "Responding to a User Click on an SVG Image", the ID attribute of each SVG element in your image is important when making the image dynamic. For this reason, it is important to handle your ID attributes carefully.
There are a couple of different tricks for this. One great way is to give your SVG image an ID immediately after creating it, as shown here:
|$svg_rootElement = SVG_New ($width;$height;$title)|
After that, you can then only name the elements that you want to respond to clicks. Be sure to make the names varied from "MainDocID" (or whatever you choose in its place). This works well because when you click on elements without ID attributes, they act as if they were transparent and the click falls down to the top-most element with an ID attribute. Therefore every time you click anywhere that you haven't defined your "clickable" elements, the click falls through to the image ID "MainDocID" and you can handle all of those clicks in the same way.
Another way you can handle the issue is to call SVG_SET_ID after every element you create. You can use the same value for the ID of elements that you want to be unresponsive to clicks with this strategy. Something important to keep in mind though is to draw your image with the responsive elements on top. Since all of your elements are given IDs, they will all respond as if they are clicked on when you try to get the "clicked" element's ID.