
var windows = new Array();
function launchWin(name, url, width, height) {
 
  var defaultOptions = "location=no,status=no,toolbar=no,personalbar=no,menubar=no,directories=no,";
  var winleft = (screen.width - width) / 2;
  var winUp = (screen.height - height) / 2;
 
  defaultOptions += "scrollbars=no,resizable=yes,top=" + winUp + ",left=" + winleft + ",";
  defaultOptions += "width=" + width + ",height=" + height;
  launchWinWithOptions(name, url, defaultOptions);
}
// Open a window with given name, url, and options list
function launchWinWithOptions(name, url, options) {
 
  if (! windowExists(name)) {
    var winVar = window.open(url, name, options);
    windows[windows.length] = winVar;
    return winVar;
  }
  else{
    var theWin = getWindow(name);
    theWin.focus();
  }
}
function windowExists(name) {
 
  for (var i = 0; i < windows.length; i++) {
 
    // IE needs a try/catch here for to avoid an access violation on windows[i].name
    // in some cases.
    try {
      if (windows[i].name == name) {
        return true;
      }
    }
    catch (exception) {
    }
  }
 
  return false;
}

