I am not understanding the exact flow of your actions, but it seems that you might be able to build the JavaScript first and then execute it at once.
For example in php you do something like this
PHP Code:
$my_javascript = '';
while ($condition == true){
$my_javascript .= 'popupscript($some params)';
}
$xtpl->assign('POPUPSCRIPTLOGIC',$my_javascript);
In your template
you'll do
<script language="javascript" >
{POPUPSCRIPTLOGIC}
</script>
Your POPUPSCRIPTLOGIC will contain sequence of js calls that invokes the popups
Bookmarks