// TEMPLATE_START.JS  Writes a block of html to the calling document.
//  TEMPLATE_START is called immediately after the BODY tag of an HTML file,
//  and TEMPLATE_END is called immediately before the </BODY> tag.
//  Together, they display the enclosed HTML code in a large portion of the upper-right of the window.
//  To the left, a table of contents is displayed.
//  At the bottom, a footer is displayed.

//  Author: A. Marut


var NUM_CHAPTERS = 9;
var LAST_CHAPTER_WITH_SOURCE_CODES = 4; // Codes currently appear in Chapters 1-4 and Appendices B and C.


document.write("<table border=\"0\" cellspacing=\"0\" width=\"1157\">\
    <tbody><tr><td class=\"menu\" style=\"border-right: 1px solid red\;\" nowrap=\"nowrap\" valign=\"top\" width=\"307\">");


document.write("<h2 style=\"margin-top: -1px\;\"><font color=\"#000080\"><font size=\"1\">");

for(var i=0; i<28; i++) {
    document.write("\&nbsp\;");
}

document.write("\
    </font></font></h2>\
    <h2 style=\"margin-top: -1px\; margin-bottom: 0pt\;\"><font color=\"#000080\">");

for(i=0; i<12; i++) {
    document.write("\&nbsp\;");
}

document.write("</font><font color=\"#000080\" face=\"Arial\">Contents</font></h2>");

document.write("<ul>");

document.write("<li><font color=\"#000080\" face=\"Arial\" size=\"2\"><a href=\"index.html\"><font color=\"#000080\">Home</font></a></font></li>");

for (chapterNumber = 1; chapterNumber <= NUM_CHAPTERS; chapterNumber++) {
    document.write("<li><font color=\"#000080\" face=\"Arial\" size=\"2\">");

    if (document.URL.indexOf("chapter" + chapterNumber + ".htm") != -1) {
        document.write("<a href=\"chapter" + chapterNumber + ".html\">");
        document.write("<font color=\"#000080\">Chapter " + chapterNumber + "</font>");
        document.write("</a>");
        document.write("<ul>");
        if (chapterNumber <= 4) {
            document.write("<li><font face=\"Arial\" size=\"2\" color=\"#000080\"><a href=\"chapter" + chapterNumber + ".htm\"><font color=\"#000080\">Source codes</font></a></font></li>");
        }
        document.write("<li><font face=\"Arial\" size=\"2\" color=\"#000080\"><a href=\"chapter" + chapterNumber + ".pdf\"><font color=\"#000080\">Manual (pdf)</font></a></font></li>\
            </ul>");
    } else {
        document.write("<a href=\"chapter" + chapterNumber + ".html\">");
        document.write("<font color=\"#000080\">Chapter " + chapterNumber + "</font>");
        document.write("</a>");
    }
    document.write("</font></li>");
}

var appendixLetters = "abc";
for(var appendixNumber = 0; appendixNumber < appendixLetters.length; appendixNumber++) {
    var currentAppendix = appendixLetters.charAt(appendixNumber);
    document.write("<li><font color=\"#000080\" face=\"Arial\" size=\"2\">");

    if (document.URL.indexOf("appendix" + currentAppendix.toLowerCase() + ".htm") != -1) {
        document.write("Appendix " + currentAppendix.toUpperCase());
        document.write("<ul>");
        if (currentAppendix.toUpperCase() != "A") {
            document.write("<li><font face=\"Arial\" size=\"2\" color=\"#000080\"><a href=\"appendix" + currentAppendix + ".htm\"><font color=\"#000080\">Source codes</font></a></font></li>");
        }
        document.write("<li><font face=\"Arial\" size=\"2\" color=\"#000080\"><a href=\"appendix" + currentAppendix + ".pdf\"><font color=\"#000080\">Manual (pdf)</font></a></font></li>\
            </ul>");
    } else {
        document.write("<a href=\"appendix" + currentAppendix.toLowerCase() + ".html\">");
        document.write("<font color=\"#000080\">Appendix " + currentAppendix.toUpperCase() + "</font>");
        document.write("</a>");
    }
    document.write("</font></li>");

}
document.write("<li><font color=\"#000080\" face=\"Arial\" size=\"2\"> <a href=\"New-64bitRCScodes.html\"><font color=\"#000080\">New-64bit RCS codes</font></a></font></li>");

document.write("<li><font color=\"#000080\" face=\"Arial\" size=\"2\"> <a href=\"updates.html\"><font color=\"#000080\">Updates</font></a></font></li>");
document.write("<li><font color=\"#000080\" face=\"Arial\" size=\"2\"> <a href=\"page01i_feedback.html\"><font color=\"#000080\">Feedback</font></a></font></li>");
document.write("<li><font color=\"#000080\" face=\"Arial\" size=\"2\"> <a href=\"page01j_people.html\"><font color=\"#000080\">People</font></a></font></li>");
document.write("<li><font color=\"#000080\" face=\"Arial\" size=\"2\"> <a href=\"links.html\"><font color=\"#000080\">Some Links</font></a></font></li>");
document.write("<li><font color=\"#000080\" face=\"Arial\" size=\"2\"> <a href=\"http://www.mathworks.com/\"><font color=\"#000080\">MathWorks, Inc.</font></a></font></li>");

document.write("</ul>");

document.write("\
    <p><span style=\"font-family: Times New Roman\;\"><font size=\"2\">\
    This work has been supported by \
    <a href=\"http://www.nsf.gov\"><font color=\"#000080\">National Science Foundation</font></a>, </p><p> Grant #0231312 </p><p>\
   (<a href=\"http://www.ece.wpi.edu/People/snm.html\"><font color=\"#000080\">Sergey N. Makarov</font></a> and \
    <a href=\"http://www.egr.msu.edu/%7Ekempel/\"><font color=\"#000080\">Leo C. Kempel</font></a>)</font></span></p>");

document.write("</td><td class=\"content\" width=\"845\">");

