var newspeakWindow;
  
var newWidth       =  600;
var newFmTop       =  20;
var newFmBottom    =  60;
var newHeight      =  screen.height - (newFmTop + newFmBottom);

var newFmRightEdge =  40;
var newHorizPosition = screen.width - (newWidth + newFmRightEdge);
var newVertPosition  = newFmTop;
var newspeakWindowName    = "Newspeak";
var newStyleStr              = "toolbar=no, scrollbars=yes, resizable=yes, fullscreen=no, location=no";
    newStyleStr = newStyleStr + ", width=" + newWidth  + ", height=" + newHeight;
    newStyleStr = newStyleStr + ", top="   + newVertPosition + ", left="   + newHorizPosition;
    
/*  -----------------------------openNewspeak(link)----------------------------  *
 * The function is used to open a supplemental window in which the user can        * 
 * display the Newspeak for reference to defined terms used by the site.            *
 *                                                                                 *
 *  Note:  When a window is closed, it still exists, but when typeof is applied    *
 *  to it, typeof returns 'undefined' which typeof is not supposed to ever retun.  *
 *  So I have some code to check that.                                             *
 *                                                                                 *
 *  openNewspeak() calling openNew1() calling openNew2() was necessary because  *
 *  when frames are used, there can be a thread problem.  In this case, the        *
 *  openNewspeak () function was looking for this.newspeakWindow.bottomnewframe,  *
 *  before it was instantiated.                                                    *
/*  ------------------------------------------------------------------------------ */
function openNew1 () {
  try {
    if (this.newspeakWindow) {
      if (this.newspeakWindow.bottomnewframe) {
        var ok = openNew2(this.link);
        if (!ok) {
          return;
        }
      } else {
        throw "Err2";
      }
    } else {
      throw "Err1";
    }
  } catch (err) {
    if (err=="Err1") {
      alert ("Error-1! script-newspeak.openNew1()\nthis.newspeakWindow didn\'t instantiate");
    } else if (err=="Err2") {
      alert ("Error-2! script-newspeak.openNew1()\nthis.newspeakWindow.bottomnewframe not an object");
    } else {
      alert ("Error-3! script-newspeak.openNew1()\nunidentifified error.");
    }
  }
}

function openNew2 (link) {
  try {
    var myHref = this.newspeakWindow.bottomnewframe.location.toString();
    myHref += link;
    this.newspeakWindow.bottomnewframe.location = myHref;
    this.newspeakWindow.focus();
    return true;
  } catch (err) {
    alert("ERROR: script-newspeak.openNew2()\nunrecognized error.");
    return false;
  }
}

function openNewspeak(link) {
  var theURL = "/jsp-pages/newspeak/new-window.jsp";
  this.link = "#" + link;
  try {
    if (this.newspeakWindow === null               ||
        (typeof this.newspeakWindow) == 'undefined'||
        ((typeof this.newspeakWindow) == 'object' &&
          this.newspeakWindow.closed)) {
      this.newspeakWindow = open (theURL, this.newspeakWindowName, this.newStyleStr);
      window.setTimeout ('openNew1()', 500);
    } else if ((typeof this.newspeakWindow) == 'object') {
      var myHref = this.newspeakWindow.bottomnewframe.location.toString();
      var index = myHref.indexOf ('#');
      if (index >= 0) {
        myHref = myHref.substring(0, index);
      }
      myHref += this.link;
      this.newspeakWindow.bottomnewframe.location = myHref;
      this.newspeakWindow.focus();
    } else {
      alert("ERROR IN openNewspeak() -- uncovered type");      
    }
  } catch (err) {
    alert("ERROR IN openNewspeak()");
  }
}

/*    
    alert("CRAP");
    if (typeof topnewframe != 'object') {
      m += "\ntopnewframe is not an object."
      err.name = "Error 3";
      err.message = m;
      throw(err);
    }
    if (typeof bottomnewframe != 'object') {
      m += "\nbottomnewframe is not an object."
      err.name = "Error 4";
      err.message = m;
      throw(err);
    }
    
    // Assign focus to newspeakWindow
    var myHref = bottomnewframe.location.toString();
    var index = myHref.indexOf("#");
    if (index >= 0) {
      myHref = myHref.substring(0, index)
    }
    myHref += link;
    m += "\nadjusted href is: " + myHref;
    bottomnewframe.location = myHref;
    this.newspeakWindow.focus();
 else if (newspeakWindow.closed) {
      this.newspeakWindow = open (theURL, this.newspeakWindowName, newStyleStr);  
      alert("closed: " + (typeof this.newspeakWindow.bottomnewframe));
    } else if ((typeof this.newspeakWindow) == 'object') {
      alert("OK: " + (typeof this.newspeakWindow.bottomnewframe));
    } else {
      m += "\nError: newspeakWindow is not an object";
      return;
      err.name = "Error 1";
      err.message = m;
      throw(err);
    }
    m += "\nnewspeakWindow.bottomnewframe: " + typeof this.newspeakWindow.bottomnewframe;
*/


