function launchInPopup(url) {
  config = "menubar=0,resizable=1,scrollbars=0,toolbar=0,location=0,directories=0,status=0,top=0,left=0";
  openWindow(url, "launch_popup", config)
}

function launchInNewWindow(url) {
  config = "menubar=1,resizable=1,scrollbars=1,toolbar=1,location=1,directories=1,status=1,top=0,left=0"
  openWindow(url, "launch_window", config)
}

function openWindow(url, window_name, config) {
  child_window = window.open(url, window_name, config);

	// continually refresh the parent window as long as the child window is still open
  // to keep the session alive
  keepAlive = function() {
    if (childIsClosed(child_window)) {
      return true
    } else {
      new Ajax.Request(sessionKeepAliveUrl, {method: 'get', onSuccess: function(){ setTimeout('keepAlive();', 60000) }})      
    }
  }
  
  keepAlive()

}

function childIsClosed(child_window) {
  try {
    if (child_window.closed) {
      // we throw because IE throws an exception when checking closed, so lets be stupid in firefox too
      throw('closed');
    } else {
      return false
    }
  }
  // we just catch any exception because it seems like child_window.closed raises an exception in IE when the window is closed
  catch(exception) {
    return true
  }
}
