Try locating the two scripts in different directories. If this is one script you'll have to split it..............
I know that when you use the servers authentication you can only password protect directories. When password protected access to a file in that directory will require authentication by the server.
If the first authentication is successful the browser then stores the username and password in a file on the client side machine. Only directoires can be password protected by the server, so each further request for a file in the same directory by the browser requires authencation just like the first. As the user has already entered his details once these are passed in the HTTP header automatically.
As only directories can be password protected on the server the browser stores the following:
Therefore if another file in the same directory is requested and that file contains PHP which fools the browseri into authenticating it will fail to validate if the username and password are different. On entering the correct username and password the credentials for that directory are overwritten.
So locating the php file for the window that opens in another directory should cure it.