<?php
/*
author: Timotheus Pokorra (timotheus@pokorra.de)
file: toc.php
autumn 2002
feel free to use and modify
no guarantuee
*/
?>

<?php


    function showTableOfContentsChapter(&$chapter, $printword)
    {
        $s = "";
        if ($chapter['chapterDepth'] < 4)
             $s = $chapter['chapterNum']." ";
        else
             echo "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
        if ($chapter['chapterDepth'] == 1)
             echo "<br/>\n";
        if ($chapter['chapterDepth'] > 1)
             echo "&nbsp;&nbsp;\n";
        if ($chapter['chapterDepth'] > 2)
             echo "&nbsp;&nbsp;\n";
        if ($chapter['chapterDepth'] > 4)
             echo "&nbsp;&nbsp;\n";
        echo "<a href='#".$chapter['chapterNum']."'>".$s;
		$title = showContentParagraph($chapter['title'], $book, $printword, -1);
		if ($chapter['chapterDepth'] == 1)
			$title=strtoupper($title);
		echo $title;
        echo "</a><br>\n";
        if ($chapter['struct'] != 0)
            foreach($chapter['struct'] as $item)
            {
                if ($item['type'] == 'chapter')
                   showTableOfContentsChapter($item['value'], $printword);
            }
    }

    function showTableOfContents(&$book, $printword)
    {
		if ($printword)
			return;

        foreach($book['chapters'] as $chapter)
        {
            showTableOfContentsChapter($chapter, $printword);
        }
    }


?>