/*
 * meNav Client-Side Navigation Script
 *
 * Copyright 2003 Thomas Meyer. All rights reserved.
 *
 */

var defaultfile = "index.htm";

if (document.URL.substring(0,4) == "http")
    var root = "http://www.till.ch/";
else
    var root = "file:///Users/me/Sites/till.ch/public/";
    
var itemcount = 0;

var filename = document.URL.substring(root.length,document.URL.length);

// if filename ends with a /, we are the default file of a server subdirectory
if (filename.substring(filename.length-1,filename.length) == "/")
    filename += defaultfile;

// if filename is empty, we are at the server root directory
if (filename == "")
    filename = defaultfile;

// cut off everything after #
var ind = filename.indexOf('#',0);
if (ind > 0)
    filename = filename.substring(0,ind);

// cut off everything after ?
var ind = filename.indexOf('?',0);
if (ind > 0)
    filename = filename.substring(0,ind);

// this will contain the array position of our menu item
var myIndex = -1;

var tex = new Array();		// link texts
var url = new Array();		// link urls
var lev = new Array();		// link levels
var bgc = new Array();		// background color
    
var ourIndex = -1;

var navBoxBgCol = "white";


function openNavBox() {
  //  document.write('filename: *' + filename + '*<BR>');
   
    // open main table
    document.write('<TABLE CELLSPACING=10 CELLPADDING=0 BORDER=0>');
    document.write('<TR><TD VALIGN="TOP">');
    
    // open navigation table
    document.write('<TABLE CELLSPACING=0 CELLPADDING=3 BORDER=0 WIDTH="100%" BGCOLOR="' + navBoxBgCol + '">');

    // navigation header row
//    document.write('<TR BGCOLOR="#009A56">');
    document.write('<TR BGCOLOR="#5FB98E">');
    document.write('<TD VALIGN="middle" ALIGN="left" STYLE="text-align: center;"><A HREF="http://www.till.ch" CLASS="schriftzugklein">www.till.ch</A></TD>');
    document.write('</TR>');
    }
    
    
function closeNavBox() {
    
    // close navigation table
    document.write('</TABLE>');
    document.write('</TD>');
    document.write('<TD ROWSPAN=2 ALIGN="LEFT" VALIGN="TOP">');

    // open outer content table
    document.write('<TABLE BORDER=0 CELLSPACING=0 CELLPADDING=0 WIDTH="580" BGCOLOR="white">');
    
    // open green header row
    document.write('<TR BGCOLOR="#5FB98E"><TD>');

    // open main header table
    document.write('<TABLE BORDER=0 CELLSPACING=0 CELLPADDING=3 WIDTH="100%"><TR>');
    
    document.write('<TD>');
    document.write('<TABLE BORDER=0 CELLSPACING=0 CELLPADDING=0><TR>');
    document.write('<TD VALIGN="middle" ALIGN="left">');
    document.write('<A HREF="http://www.till.ch">');
    document.write('<IMG SRC="' + root + 'bilder/logo_till_klein.jpg" ALT="Till logo" WIDTH=24 HEIGHT=24 BORDER=0 ALIGN="middle">');
    document.write('</A>');
    document.write('</TD>');
    document.write('<TD CLASS="schriftzug">&nbsp;Theaterp&auml;dagogik</TD>');
	document.write('<IMG SRC="' + root + 'bilder/logozhdk_0.jpg" ALT="zhdk logo" WIDTH=130 HEIGHT=24 BORDER=0 ALIGN="right">');
    document.write('</TR></TABLE>');
    document.write('</TD>');
    
    document.write('<TD ALIGN="right" NOWRAP>');
    
    if (myIndex > 0)
        document.write('<A HREF="' + root + url[myIndex-1] + '" CLASS="gotop" STYLE="color: white;" TITLE="Vorhergehende Seite">&larr;</A>&nbsp;&nbsp;');
    
    if (myIndex > -1) {
        if (myIndex < (itemcount - 1))
            document.write('<A HREF="' + root + url[myIndex+1] + '" CLASS="gotop" STYLE="color: white;" TITLE="N&auml;chste Seite">&rarr;</A>');
        else
            document.write('<A HREF="' + root + url[0] + '" CLASS="gotop" STYLE="color: white;" TITLE="N&auml;chste Seite">&rarr;</A>');
        }

    document.write('</TD></TR>');

    
    // close main header table
    document.write('</TR></TABLE>');
    
    // close green header row
    document.write('</TD></TR>');

    // open inner content table
    document.write('<TR><TD>');
    document.write('<TABLE BORDER=0 CELLSPACING=0 CELLPADDING=24 BACKGROUND="' + root + '" WIDTH="100%">');
    document.write('<TR><TD>');
    
    }


function finishContent(changedDate) {

    // write arrows
    document.write('<BR><BR>');
    document.write('<CENTER>');

    if (myIndex > 0)
        document.write('<A HREF="' + root + url[myIndex-1] + '" CLASS="gotop" TITLE="Vorhergehende Seite">&larr;</A>&nbsp;&nbsp;');
    
    document.write('<A HREF="#top" CLASS="gotop" TITLE="Zur&uuml;ck zum Seitenanfang">&uarr;</A>');
    
    if (myIndex > -1)
        if (myIndex < (itemcount - 1))
            document.write('&nbsp;&nbsp;<A HREF="' + root + url[myIndex+1] + '" CLASS="gotop" TITLE="N&auml;chste Seite">&rarr;</A>');
        else
            document.write('&nbsp;&nbsp;<A HREF="' + root + url[0] + '" CLASS="gotop" TITLE="N&auml;chste Seite">&rarr;</A>');
    
    document.write('<BR><BR>');
    
    // write disclaimer
    document.write('<SPAN CLASS="low">');
    
    if (changedDate != null)
        document.write('Letzte &Auml;nderung: ' + changedDate + '<BR>');
        
    document.write('&copy; 2003 Till. Alle Rechte vorbehalten.');
    document.write('</SPAN>');
    
    document.write('</CENTER>');

    // close inner content table
    document.write('</TD></TR></TABLE>');
    
    // close outer content table
    document.write('</TD></TR></TABLE>');
    
 //   document.write('<TR><TD></TD></TR>');
    
    // close main table
    document.write('</TD></TR></TABLE>');
    }


function add(inLevel,inText,inURL,inBGC) {

    lev[itemcount] = inLevel;
    tex[itemcount] = inText;
    url[itemcount] = inURL;
    
    if (arguments.length == 4)
        bgc[itemcount] = inBGC;
    else
        bgc[itemcount] = "";
        
    itemcount++;    
    }
    

function prepareContent(omitExtraNavScript) {
    
    var bgCol = "";
    var insideTable = false;
    
    document.write('<A NAME="top"></A>');
    
    openNavBox();
    
    // loop through all items to find our parent item
    var visibleParent = 0;
    var currentParent = 0;
    
    for (index=0;index<itemcount;index++) {
        if (lev[index] == 1)
            visibleParent = index;
            
        if (filename == url[index]) {
            myIndex = index;
            break;
            }
        }
    
    if (myIndex == -1)
        visibleParent = -1;
        
    for (index=0;index<itemcount;index++) {
        
        if (bgc[index] != '')
            bgCol = bgc[index];
        else
            bgCol = navBoxBgCol;

        if (lev[index] == 1) {
        
            currentParent = index;
            
            if (insideTable == true) {
                document.write('</TABLE></TD></TR>');
                insideTable == false;
                }
            
            document.write('<TR BGCOLOR="' + bgCol + '"><TD><TABLE BORDER=0 CELLSPACING=0 CELLPADDING=1>');
            insideTable = true;
            }
        
        // do 
        if (filename == url[index]) {
        
            ourIndex = index;
            
            document.write('<TR>');
            document.write('<TD VALIGN="top" CLASS="navMark" STYLE="color: black;">&rarr;&nbsp;</TD>');

            switch(lev[index]) {
                case 2:
                    document.write('<TD CLASS="navMark" STYLE="color: ' + bgCol + ';">&nbsp;&nbsp;</TD>');
                    document.write('<TD VALIGN="top" CLASS="stufe2titel">' + tex[index] + '</TD>');
                    break;
            
                case 1:
                defaultcase:
                    document.write('<TD VALIGN="top" CLASS="stufe1titel" COLSPAN=2>' + tex[index] + '</TD>');
                    break;
                }
                
            document.write('</TR>');
            }
        else if ( (currentParent == visibleParent) || (lev[index] == 1) ) {
                
            document.write('<TR>');
            document.write('<TD CLASS="navMark" STYLE="color: ' + bgCol + ';">&rarr;&nbsp;</TD>');
            
            switch(lev[index]) {
                case 2:
                    document.write('<TD CLASS="navMark" STYLE="color: ' + bgCol + ';">&nbsp;&nbsp;</TD>');
                    document.write('<TD VALIGN="top"><A CLASS="stufe2link" HREF="' + root + url[index] + '">' + tex[index] + '</A></TD>');
                    break;
                    
                case 1:
                defaultcase:
                    document.write('<TD VALIGN="top" COLSPAN=2>');
                    document.write('<A CLASS="stufe1link" HREF="' + root + url[index] + '">' + tex[index] + '</A></TD>');
                    break;
                }

            document.write('</TR>');
            }
        }
        
            if (insideTable == true) {
                document.write('</TABLE></TD></TR>');
                insideTable == false;
                }
              
    closeNavBox();
    
    }
    

