var PopupWindow; function OpenPopupWindow(URL, WindowName, WindowProps) { PopupWindow = window.open(URL, WindowName, WindowProps); if(PopupWindow != null) { PopupWindow.focus(); document.body.onunload = DoUnload; } else { alert("It appears that your browser is blocking popup windows. Please enable popups for this site and try again. Thank you."); } } function DoUnload() { //alert(PopupWindow.KeepMe); if(PopupWindow != null) { try { if(PopupWindow.KeepMe != null) { if(!PopupWindow.KeepMe) { PopupWindow.close(); } else { PopupWindow.KeepMe = false; PopupWindow.focus(); } } else PopupWindow.focus(); } catch(e) { PopupWindow = null; } } }