var opened = false; var nome = ""; function NewWindow(mypage,myname,w,h,scroll){ if(mypage.indexOf('f=file.jpg') == -1){ if(opened && nome == myname){win.close();opened = false;} LeftPosition = (screen.width) ? (screen.width-w)/2 : 0; TopPosition = (screen.height) ? (screen.height-h)/2 : 0; settings = 'height='+h+',width='+w+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scroll+',status=no, toolbar=no' win = window.open(mypage,myname,settings); nome = myname; opened = true; if(win.window.focus){win.window.focus();} } }