// Open a popup window using the settings specified
// by the calling link. The location of the new popup
// is pulled from the href entry in the link. This way
// the link will work even if the user has JavaScript 
// turned off. The same goes for the name of the new
// window. It is taken from the target setting in the
// calling link.
//
// The first parameter MUST be the link object. The easiest
// way to do this is to use the THIS object. For example...
//
// <a href='http://www.schworak.com' target='MyWin' onclick='return NewWin(this);'>
//
// You may also add any other normal window options as parameters 
// such as scrollbars, menubars, height, width or what ever else.
// Simply seperate each parameter with commas and place them in quotes.
//
// <a href='http://www.schworak.com' target='MyWin' onclick='return 
// NewWin(this,"scrollbars=no","resizable=no","height=400","width=600");'>
//
// In this way, you do not need to pass in a URL or TARGET to the
// function. This information is pulled right from the link. And if the
// user has disabled JavaScript, your link will still open a new window
// because of the TARGET command in the link itself. NewWin always returns
// FALSE which stops the link from being followed twice when the script
// runs properly.
//
// You can specify any other window options after the THIS parameter.


function NewWin()
{
  var arg = arguments;
  var url = "";
  var target = "_blank";
  var scrollbars = "scrollbars=yes";   // These are defaults that over
  var menubar = "menubar=no";          // ride the user's system defaults
  var location = "location=no";        // If you would rather use the
  var hotkeys = "hotkeys=no";          // system default you may delete
  var directories = "directories=no";  // the override default from this
  var resizable = "resizable=yes";     // list and the IF block below.
  var toolbar = "toolbar=yes";         // 
  var extra = "";                      //
  var reset = 0;                       // No options if "reset" is passed
  var a;

  if (arg.length > 0)
  {
    var link = arg[0];

    url = link.href;
    if (link.target != "") target = link.target;
  }
  for (i = 1; i < arg.length; i++)
  {
    a = arg[i];
    if (String(a).substring(0,10) == "scrollbars")       scrollbars = a;
    else if (String(a).substring(0,7) == "menubar")      menubar = a;
    else if (String(a).substring(0,8) == "location")     location = a;
    else if (String(a).substring(0,7) == "hotkeys")      hotkeys = a;
    else if (String(a).substring(0,11) == "directories") directories = a;
    else if (String(a).substring(0,9) == "resizable")    resizable = a;
    else if (String(a).substring(0,7) == "toolbar")      toolbar = a;
    else if (a == "reset") reset = 1;
    else if (extra == "") extra = a;
    else extra = extra + "," + a;
  }
  if (reset) 
  {
    extra = "";
  }
  else
  {
    if (extra != "") extra = extra + ",";
    extra = extra + scrollbars 
          + "," + menubar
          + "," + location
          + "," + hotkeys
          + "," + directories
          + "," + resizable
          + "," + toolbar;
  }

  var MyWin=window.open(url, target, extra);
  MyWin.focus();
  return false;
}
