/* 
Um ein neues Menu hinzuzufuegen, bitte folgende Schritte durchfuehren:
1. Frameset fuer das neue Menu erstellen.
2. Die menuNr in diesem Script um eins erhoehehen.
3. Einen neuen Variablensatz fuer das Menu analog zu den vorhandenen anlegen
	(also menulength, menuName, regBackColor und hlBackColor definieren.
4. Die Arrays subMenus und subMenuLoc aktualisieren.

das war's.
*/

var menuNr=4;				/*Anzahl der verschiedenen Menus*/

var menulength=new Array(menuNr);	/*Anzahl der Eintraege des Menus*/
var menuName=new Array(menuNr);		/*Array mit den Namen des Menus */
var regBackColor=new Array(menuNr);	/*normaler Background des Menus */
var hlBackColor=new Array(menuNr);	/*Highlight - Farbe des Menus   */

/* Menudistribution */

/* Dient der automatischen Erkennung des aktuellen Menupunkts. Das
   distribution - Array speichert Schluesselwoerter in den Adressen 
   der dargestellten Seiten, waehrend das subMenu - Array speichert,
   ob auch ein unterMenu kontrolliert werden muss (-1 falls nicht, 
   sonst Nr. des Untermenus).
   Das subMenu ist nur einmal vorhanden, da hoffentlich Untermenus
   von Untermenus nie erforderlich werden. Das distribution-Array
   hingegen wird fuer jedes einzelne Menu gespeichert. Die jeweilige
   Implementation findet sich bei den einzelnen Menus.
*/

var distribution=new Array(menuNr);
subMenus=new Array(-1,-1,1,2,3);
subMenuLoc=new Array("nil","nil","http://www.informatik.uni-freiburg.de/proglang/teaching/submenu.html","http://www.informatik.uni-freiburg.de/proglang/research/submenu.html","http://www.informatik.uni-freiburg.de/proglang/offers/submenu.html");

/* Menu 0: Hauptmenu */
menulength[0]=7;
menuName[0]=new Array("dummy","home","personal","lehre","forschung","stellen","dummy");
distribution[0]=new Array("dummy","welcome","personal","teaching","research","offers","dummy");
regBackColor[0]="#CCCCCC";
hlBackColor[0]="#BBBBBB";

/* Menu1: Lehre */
menulength[1]=4;
menuName[1]=new Array("aktuell","kurse","alle","dipl")

/* WICHTIG! Diese Distribution beim Einfuegen eines neuen Semesters 
            aendern! */
distribution[1]=new Array("ss2004|aktuell","lehre","old|toread|1999|2000|2001|2002|2003","dummy");
regBackColor[1]="#EEEEEE";
hlBackColor[1]="#CCCCCC";

/* Menu 2: Forschung */
menulength[2]=4;
menuName[2]=new Array("themenbereich","publikationen","dipl","projekte");
distribution[2]=new Array("h/research","publications","dipl","projects|software");
regBackColor[2]="#EEEEEE";
hlBackColor[2]="#CCCCCC";

/* Menu 3: Stellen */
menulength[3]=3;
menuName[3]=new Array("dipl","hiwi","mit");
distribution[3]=new Array("dipl","hiwi","mitarb");
regBackColor[3]="#EEEEEE";
hlBackColor[3]="#CCCCCC";

var subMenuColorDummy;

function highLight(menunr,frameNr) {
	for (i=0; i<menulength[menunr]; i++) {
	}
	parent.frames[frameNr].document.bgColor=hlBackColor[menunr];
}

function update() {
	/* In welchem Hauptmenupunkt sind wir? */
	var mainTarget;
	for (i=0; i<menulength[0]; i++) {
		if (locationTest(document.location.href,0,i)) {
			mainTarget=i;
			top.frames[0].frames[i].document.bgColor=hlBackColor[0];
		} else {
			top.frames[0].frames[i].document.bgColor=regBackColor[0];
		}
	}

	/* Dummerweise ist der IIF-Link da, darum muss mainTarget um 1
		vermindert werden */
	mainTarget--;
	
	/* Gibt es ein Untermenu? */
	
	if (subMenus[mainTarget]>0) {

		/* Wird das korrekte Untermenu dargestellt? */
		if (parent.frames[0].location.href!=subMenuLoc[mainTarget]) {
			parent.frames[0].location.replace(subMenuLoc[mainTarget]);
			parent.frames[1].location.reload();
		}
		else {
		/* jetzt den korrekten Unterpunkt highlighten */
		submenuHL(mainTarget);
		}
	} 
}

function firstHighLight(menunr) {
	document.bgColor=hlBackColor[menunr];
}

function firstRegular(menunr) {
	document.bgColor=regBackColor[menunr];
}

/* Testet, ob die Schlüsselworte des distribution-Arrays an Stelle j im
   übergebenen Pfad vorkommen */
function locationTest(pfad, nrOfMenu, j) {
   targets=distribution[nrOfMenu][j].split("|");
   temp=false;
   for (k=0; k<targets.length; k++) {
	if (pfad.indexOf(targets[k])>-1) {
 	    temp=true;
	}
   }
   return temp;
}	

function submenuHL(mainTarget) {
		for (i=0; i<menulength[subMenus[mainTarget]]; i++) {
			if (locationTest(document.location.href,subMenus[mainTarget],i))
			{
				parent.frames[0].frames[i].document.bgColor=hlBackColor[subMenus[mainTarget]]; 
			} else {
				parent.frames[0].frames[i].document.bgColor=regBackColor[subMenus[mainTarget]];
			}
		}
}
