var pop = null;

function popdown() {
 if (pop && !pop.closed) pop.close();
}

function popup(obj,w,h) {
  var url = (obj.getAttribute) ? obj.getAttribute('href') : obj.href;
  if (!url) return true;
  if (navigator.userAgent.toLowerCase().indexOf("msie") >= 0) w = (w) ? w += 38 : 840;
  else w = (w) ? w += 16 : 820;
  h = (h) ? h += 65 : 660;
  w = (w < screen.width) ? w : screen.width - 10;
  h = (h < screen.height) ? h : screen.height - 30;
  var left = (document.body.offsetWidth - w) / 2;
  left = (left > 0) ? left : 0;
  var top = (screen.height - h - 100) / 2;
  top = (top > 0) ? top : 0;
  var args = 'width='+w+',height='+h+',left='+left+',top='+top+',scrollbars=yes,resizable=yes';
  popdown();
  pop = window.open(url,'',args);
  return (pop) ? false : true;
}

window.onunload = popdown;
window.onfocus = popdown;