function opentarget (form, features, windowName) {
  if (!windowName)
    windowName = 'formTarget' + (new Date().getTime());
  form.target = windowName;
  open ('', windowName, features);
}

function stayontop() {
    setTimeout("checkparent()",4000); 
}

function closeWindow() {
    self.close();
}

function checkparent() {
    self.onerror = closeWindow;
    parentWindow = opener.location.href;
}
