/*------------------------------------------------------------------- 
Author's Statement:
This script is based on ideas of the author.
You may copy, modify and use it for any purpose. The only condition is
that if you publish web pages that use this script you point to its
author at a suitable place and don't remove this Statement from it.
It's your responsibility to handle possible bugs even if you didn't
modify anything. I cannot promise any support.
Dieter Bungers
GMD (www.gmd.de) and infovation (www.infovation.de)
--------------------------------------------------------------------*/

if (navigator.appName.toLowerCase().indexOf("explorer") > -1) {
  var mdi = textSizes[1];
} else {
  var mdi = textSizes[2];
}

function reDisplay(currentNumber,currentIsExpanded) {
  toc.document.open("text/html","replace");
  toc.document.write("<HTML>\n<HEAD>\n<TITLE>ToC</TITLE>\n<LINK REL=\"stylesheet\" HREF=\"cyprus.css\">\n<STYLE TYPE=\"text/css\">\nA {\n font-family: ", fontLines, ";\n font-weight: bold;\n font-size:", mdi, "em;\n color: rgb(0,0,0);");
  toc.document.write(";\n text-decoration: none;\n}\n</STYLE>\n</HEAD>\n<BODY>\n<IMG SRC=\"pics/icslogo.gif\" ALT=\"Institute of Cypriot Studies\">\n<TABLE BORDER=\"0\" CELLSPACING=\"1\" CELLPADDING=\"0\">\n<TR>\n");
  var currentNumArray = currentNumber.split(".");
  var currentLevel = currentNumArray.length - 1;
  var scrollY = 0, addScroll = true, theHref = "";
  for (i = 0; i < tocTab.length; i++) {
    thisNumber = tocTab[i][0];
    var isCurrentNumber = (thisNumber == currentNumber);
    if (isCurrentNumber) theHref = tocTab[i][2];
    var thisNumArray = thisNumber.split(".");
    var thisLevel = thisNumArray.length-1;
    var toDisplay = true;
    if (thisLevel > 0) {
      for (j = 0; j < thisLevel; j++) {
        toDisplay = (j>currentLevel)?false:toDisplay && (thisNumArray[j] == currentNumArray[j]);
      }
    }
    thisIsExpanded = toDisplay && (thisNumArray[thisLevel] == currentNumArray[thisLevel])
    if (currentIsExpanded) {
      toDisplay = toDisplay && (thisLevel<=currentLevel);
      if (isCurrentNumber) thisIsExpanded = false;
    }
    if (toDisplay) {
      if (i == 0) {
        toc.document.write("<TD COLSPAN=\"", (nCols+1), "\">", tocTab[i][1], "</TD>\n</TR>\n<TR>\n");
        for (k = 0; k < nCols; k++) {
          toc.document.write("<TD>&nbsp;</TD>\n");
        }
        toc.document.write("<TD WIDTH=\"240\">&nbsp;</TD>\n</TR>\n");
      } else {
        if (addScroll) scrollY += mdi*25;
        if (isCurrentNumber) addScroll = false;
        var isLeaf = (i == (tocTab.length - 1)) || (thisLevel >= (tocTab[i+1][0].split(".").length - 1));
        img = (isLeaf)?"leaf":(thisIsExpanded)?"minus":"plus";
        toc.document.write("<TR>");
        for (k = 1; k <= thisLevel; k++) {
          toc.document.write("<TD>&nbsp;</TD>\n");
        }
        toc.document.write("<TD VALIGN=\"top\">\n<A HREF=\"javaScript:parent.reDisplay(\'", thisNumber, "\',", thisIsExpanded, ");\"><IMG SRC=\"pics/", img, ".gif\" WIDTH=\"13\" HEIGHT=\"12\" BORDER=\"0\"></A>\n</TD>\n<TD COLSPAN=\"");
        toc.document.write((nCols-thisLevel), "\"><A HREF=\"javaScript:parent.reDisplay(\'", thisNumber, "\',", thisIsExpanded);
        toc.document.write(");\"", ((isCurrentNumber)?" STYLE=\"color: "+currentColor+";\"":""), ">");
	toc.document.write(tocTab[i][1], "</A></TD></TR>");
      }
    }
  }
  toc.document.write("</TABLE></BODY></HTML>");
  toc.document.close();
  toc.scrollTo(0,scrollY);

  if (theHref != "") content.location.href = theHref;
}
