Thanks Victor this inspired me to the obvious and I got it fixed.
I am placing the code on the frontpage, but have been testing in a static page.
Obviously the static page creates the dialog box no matter what goes into the custom code!
On the frontpage it is working perfectly.
Thanks so much or jogging this useless brain of mine.
