This is a very hard task. Im not too sure if PHP is the solution.
Firstly you'll need a session to track the user exactly where he/she is. When arrived. Lastest time of activity.
There will need to be a function or something that doesnt do anything until the Admin looks at the session and wants the window to open.
Once the Admin does that. When the user nexts clicks on a link the function should come into affect. Which will open the window.
When the windows opens you will probably need to use a java chat. Within that i think the chat can tell if the user has closed the window or the session has expired.