mi pare che la variabile che punta alla popup, dovrebbe essere esterna alla funzione, altrimenti la sua vita finisce al termine della procedura :master:

codice:
var jspopup = null;
function open_img(file, w, h) 
{ 

var l = Math.floor((screen.width-w)/2); 
var t = Math.floor((screen.height-h)/2); 

if (self.jspopup != null && jspopup.open) jspopup.close();
jspopup = window.open(file,"mywindow","width="+w+",height="+h+",top="+t+",left="+l); 

}