Excellent, thanks Mandoble.
I just finished testing though, and it looks like that wasn't my problem.
What looks like is happening, is for some reason when I click on the map after the insertion is done, it seems to call my insertion script again. Not sure if this is a bug with 'onmapsingleclick' or a problem with my script.
For now, I am just going to use a global variable, and set it to true if the script has been run, then check for that variable at the start of the script, not very elegant, but hopefully it should work.
Cheers!