var arrId;
var arrTitle;
var myWindow;

function getLongestStr(longestStr) {
  topicTitle = top.fr_content.topicTitle;
  len = topicTitle.length;
  siblingArray = top.fr_content.siblingArray;
  
  arrId = new Array(siblingArray.length);
  arrTitle = new Array(siblingArray.length);

  for (ix1 = 0; ix1 < siblingArray.length; ix1++) {
    sib = siblingArray[ix1];

    // find contentId within ContentIDArray
    if (ContentIDArray) {
      for (ix2 = 0; ix2 < ContentIDArray.length; ix2++) {
        if (ContentIDArray[ix2] == sib) {
          pos = ix2;
        }
      }
    }

    // find corresponding title
    title = ContentTitleArray[pos];

    if (title.length < 1) {
      title = "Untitled";
    }

    arrId[ix1] = sib;
    arrTitle[ix1] = title;

    if (title.length > len) {
      len = title.length;
    }
  }
  return len;
}

function show_menu() {
  topicTitle = top.fr_content.topicTitle;
  longestStr = getLongestStr();

  iwidth = longestStr*11;
  iheight = (arrId.length*45);

  var str = "height=" + iheight + ",innerHeight=" + iheight;
  str += ",width=" + iwidth + ",innerWidth=" + iwidth;

  if (window.screen) {
    var ah = screen.availHeight - 30;
    var aw = screen.availWidth - 10;

    var xc = (aw - iwidth) / 2;
    var yc = (ah - iheight) * 0.75;

    str += ",left=" + xc + ",screenX=" + xc;
    str += ",top=" + yc + ",screenY=" + yc;
  }
  if (myWindow && !myWindow.closed) {myWindow.close();}
  myWindow = window.open("", "myWindow", str);
  myWindow.focus();
  myWindow.document.writeln("<html><head><title>nav menu</title><style type='text/css'>");
  myWindow.document.writeln("a:active {color: blue; text-decoration: none;}");
  myWindow.document.writeln("a:hover {color: blue; text-decoration: none;}");
  myWindow.document.writeln("a:link {color: blue; text-decoration: none;}");
  myWindow.document.writeln("a:visited {color: blue; text-decoration: none;}");
  myWindow.document.writeln("</style></head><body bgcolor='gray'>");

  myWindow.document.writeln("<div top=0 left=0>");
  myWindow.document.writeln("<table width='100%' border='1' align='center' cellpadding='5' cellspacing='0' bordercolor='gray'>");
  myWindow.document.writeln("<th bgcolor='white'>" + topicTitle + "</th>");

  for (ix = 0; ix < arrId.length; ix++) {
    myWindow.document.writeln("<tr>");
    myWindow.document.writeln("<td bgcolor='white'><a href='#' onClick=opener.top.fr_content.location.href='" + arrId[ix] + ".htm';window.close();>" + arrTitle[ix] + "</a></td>");
    myWindow.document.writeln("</tr>");
  }

  myWindow.document.writeln("</table>");
  myWindow.document.writeln("</div>");
  myWindow.document.writeln("</body></html>");
}