Need the code that opens the popup.
Out of stack space means that your probably calling a rountine in a recursive fashion. ie. A calls B, B calls C, and C calls A at some point.
You can probably figure out what that is by letting your code run for a few minutes, then break the code (Ctrl/Break), then do a view call stack (Ctrl/L). Look at the call stack and see if you can spot a repeating pattern.
JimD.