If your serevr can handle php I would do it like this.
Instead of href-ing to a new window link to a generic php page with a parameter indicating which link was clicked, like so:
<a href=page.php?parameter="linkname">
In the php page begin with a simple test:
if (session timed out){
header (location:login_page)
}
then test for each link like so:
if (parameter==link1){
header (location:page for link1)
}
elsif (parameter==link2){
header (location:page for link 2)
}
...
I'm not sure about the exact syntax I've used, but the logic can definitely be followed in php.