﻿// JavaScript Document
var idPrefix = "mi";
var colorL1Init = "#DBEBEC";
var colorLoT = "#004E82";

function levelColor(L1Hi, L1Lo, L2Hi, L2Lo, L3Hi, L3Lo, Frame, HiT)
{
	this.L1Hi = L1Hi;
	this.L1Lo = L1Lo;
	this.L2Hi = L2Hi;
	this.L2Lo = L2Lo;
	this.L3Hi = L3Hi;
	this.L3Lo = L3Lo;
	
	this.allColor = L1Hi + L1Lo + L2Hi + L2Lo + L3Hi + L3Lo;
	this.Frame = Frame;
	this.HiT = HiT;
}

catColor = new Array();

//catColor[0] = new levelColor("#1177A4", "#DBEBEC", "#4192B6", "#70ADC8", "#F0F0F0", "#FFFFFF");
//catColor[1] = new levelColor("#1177A4", "#DBEBEC", "#4192B6", "#70ADC8", "#F0F0F0", "#FFFFFF");
catColor[0] = new levelColor("", "", "", "", "", "");
catColor[1] = new levelColor("", "", "", "", "", "");
catColor[2] = new levelColor("#1177A4", "#DBEBEC", "#1177A4", "#BFDCDD", "#1177A4", "#AAD0D2", "#1177A4", "#FFFFFF");
catColor[3] = new levelColor("#E38D00", "#F9E8CC", "#E38D00", "#F8E1C0", "#E38D00", "#F5D8A7", "#E38D00", "#FFFFFF");
catColor[4] = new levelColor("#008A0C", "#CCE8CE", "#008A0C", "#C0E2C2", "#008A0C", "#B0DBB4", "#008A0C", "#FFFFFF");
catColor[5] = new levelColor("#7E0079", "#E5CCE4", "#7E0079", "#DFC1DE", "#7E0079", "#DBB7D9", "#7E0079", "#FFFFFF");
catColor[6] = new levelColor("#107B7D", "#CFE5E5", "#107B7D", "#C6DFDF", "#107B7D", "#B9D9D9", "#107B7D", "#FFFFFF");
catColor[7] = new levelColor("#58595B", "#DEDEDE", "#58595B", "#D7D7D7", "#58595B", "#D0D0D0", "#58595B", "#FFFFFF");
catColor[8] = new levelColor("#FFCB05", "#FFF5CD", "#FFCB05", "#FFF1BB", "#FFCB05", "#FFEEAA", "#FFCB05", "#FFFFFF");
catColor[9] = new levelColor("#663366", "#cc99cc", "#663366", "#FFF1BB", "#663366", "#FFEEAA", "#663366", "#FFFFFF");
//catColor[2] = new levelColor("#1177A4", "#DBEBEC", "#1177A4", "#DBEBEC", "#F0F0F0", "#FFFFFF", "#1177A4", "#FFFFFF");
//catColor[3] = new levelColor("#E38D00", "#F9E8CC", "#E38D00", "#F9E8CC", "#F0F0F0", "#FFFFFF", "#E38D00", "#FFFFFF");
//catColor[4] = new levelColor("#008A0C", "#CCE8CE", "#008A0C", "#CCE8CE", "#F0F0F0", "#FFFFFF", "#008A0C", "#FFFFFF");
//catColor[5] = new levelColor("#7E0079", "#E5CCE4", "#7E0079", "#E5CCE4", "#F0F0F0", "#FFFFFF", "#7E0079", "#FFFFFF");
//catColor[6] = new levelColor("#107B7D", "#CFE5E5", "#107B7D", "#CFE5E5", "#F0F0F0", "#FFFFFF", "#107B7D", "#FFFFFF");
//catColor[7] = new levelColor("#58595B", "#DEDEDE", "#58595B", "#DEDEDE", "#F0F0F0", "#FFFFFF", "#58595B", "#FFFFFF");
//catColor[8] = new levelColor("#FFCB05", "#FFF5CD", "#FFCB05", "#FFF5CD", "#F0F0F0", "#FFFFFF", "#FFCB05", "#FFFFFF");
//catColor[9] = new levelColor("#663366", "#cc99cc", "#663366", "#FFF1BB", "#663366", "#FFEEAA", "#663366", "#FFFFFF");
/*catColor[0] = new levelColor("", "", "", "", "", "");
catColor[1] = new levelColor("", "", "", "", "", "");
catColor[2] = new levelColor("#1177A4", "#DCEBF1", "#4192B6", "#70ADC8", "#F0F0F0", "#FFFFFF", "#1177A4");
catColor[3] = new levelColor("#1177A4", "#DCEBF1", "#4192B6", "#70ADC8", "#F0F0F0", "#FFFFFF", "#E38D00");
catColor[4] = new levelColor("#1177A4", "#DCEBF1", "#4192B6", "#70ADC8", "#F0F0F0", "#FFFFFF", "#008A0C");
catColor[5] = new levelColor("#1177A4", "#DCEBF1", "#4192B6", "#70ADC8", "#F0F0F0", "#FFFFFF", "#7E0079");
catColor[6] = new levelColor("#1177A4", "#DCEBF1", "#4192B6", "#70ADC8", "#F0F0F0", "#FFFFFF", "#107B7D");
catColor[7] = new levelColor("#1177A4", "#DCEBF1", "#4192B6", "#70ADC8", "#F0F0F0", "#FFFFFF", "#58595B");
catColor[8] = new levelColor("#1177A4", "#DCEBF1", "#4192B6", "#70ADC8", "#F0F0F0", "#FFFFFF", "#FFCB05");*/


function MenuItem(MenuID, URL, MenuText, PathText, HeadText, ColorID, Target)
{
	this.MenuID = MenuID;
	this.URL = URL;
	this.MenuText = MenuText;
	this.PathText = PathText;
	this.HeadText = HeadText;
	this.ColorID = ColorID;
	this.Target = Target;
	
	this.drawMenu = drawMenu;
	this.Level = this.MenuID.split("_").length;
	
	this.drawMap = drawMap;
}

function drawMenu()
{
	switch (this.Level)
	{
		case 1 :
			oTable = document.getElementById("ROOT");
			oRow = oTable.insertRow(-1);
			oRow.id = idPrefix + this.MenuID + "hline";
			oCell = oRow.insertCell(-1);
			oCell.width = "100%";
			//oCell.width = 150;
			oCell.bgColor = "#FFFFFF";
			oCell.innerHTML = "<img src='_pics/empty.gif' alt='' width=1 height=1 border=0>";
			
			oRow = oTable.insertRow(-1);
			oRow.id = idPrefix + this.MenuID + "item";
//			oRow.bgColor = catColor[this.ColorID].L1Lo;
			oRow.bgColor = colorL1Init;
			oRow.onmouseover = hilite;
			oRow.onmouseout = lolite;
			oCell = oRow.insertCell(-1);
			oCell.width = "100%";
			//oCell.width = 150;
			oCell.className = "MenuItem1";
			if (this.URL == "")
				oCell.innerHTML = "<div style='width:138px;' id='" + idPrefix + this.MenuID + "' onmouseup='expandSub(this.id, " + this.ColorID + ");' class='MenuItem1A'>" + this.MenuText + "</div>";
			else
				//oCell.innerHTML = "<a id='" + idPrefix + this.MenuID + "' onmouseup='expandSub(this.id, " + this.ColorID + ");' class='MenuItem1A' href='" + this.URL + "'>" + this.MenuText + "</a>";
				oCell.innerHTML = "<div style='width:138px;'><a id='" + idPrefix + this.MenuID + "' class='MenuItem1A' href='" + this.URL + "'>" + this.MenuText + "</a></div>";
			
			oRow = oTable.insertRow(-1);
			oRow.id = idPrefix + this.MenuID + "sub";
			oRow.style.display = "none";
			oCell = oRow.insertCell(-1);
			oCell.width = "100%";
			//oCell.width = 150;
			oCell.innerHTML = "<table id='" + idPrefix + this.MenuID + "subcnt' cellpadding=0 cellspacing=0 border=0 width='100%'></table>";
			break;
		case 2 :
			var upperMenuID = this.MenuID.substring(0, this.MenuID.lastIndexOf("_"));
			oTable = document.getElementById(idPrefix + upperMenuID + "subcnt");
			oRow = oTable.insertRow(-1);
			oRow.id = idPrefix + this.MenuID + "hline";
			oCell = oRow.insertCell(-1);
			oCell.width = "100%";
			//oCell.width = 150;
			oCell.bgColor = "#FFFFFF";
			//oCell.bgColor = "#8DBDD3";
			oCell.innerHTML = "<img src='_pics/empty.gif' alt='' width=1 height=1 border=0>";
			
			oRow = oTable.insertRow(-1);
			oRow.id = idPrefix + this.MenuID + "item";
			oRow.bgColor = catColor[this.ColorID].L2Lo;
			oRow.onmouseover = hilite;
			oRow.onmouseout = lolite;
			oCell = oRow.insertCell(-1);
			oCell.width = "100%";
			//oCell.width = 150;
			oCell.className = "MenuItem2";
			if (this.URL == "")
				oCell.innerHTML = "<div style='width:132px; color:" + colorLoT + "' id='" + idPrefix + this.MenuID + "' onmouseup='expandSub(this.id, " + this.ColorID + ");' class='MenuItem2A'>" + this.MenuText + "</div>";
			else
				//oCell.innerHTML = "<a id='" + idPrefix + this.MenuID + "' onmouseup='expandSub(this.id, " + this.ColorID + ");' class='MenuItem2A' href='" + this.URL + "'>" + this.MenuText + "</a>";
				oCell.innerHTML = "<div style='width:132px;'><a style='color:" + colorLoT + "' id='" + idPrefix + this.MenuID + "' class='MenuItem2A' href='" + this.URL + "'>" + this.MenuText + "</a></div>";
			
			oRow = oTable.insertRow(-1);
			oRow.id = idPrefix + this.MenuID + "sub";
			oRow.style.display = "none";
			oCell = oRow.insertCell(-1);
			oCell.width = "100%";
			//oCell.width = 150;
			oCell.innerHTML = "<table id='" + idPrefix + this.MenuID + "subcnt' cellpadding=0 cellspacing=0 border=0 width='100%'></table>";
			break;
		case 3 :
			var upperMenuID = this.MenuID.substring(0, this.MenuID.lastIndexOf("_"));
			oTable = document.getElementById(idPrefix + upperMenuID + "subcnt");
			oRow = oTable.insertRow(-1);
			oRow.id = idPrefix + this.MenuID + "hline";
			oCell = oRow.insertCell(-1);
			oCell.width = "100%";
			//oCell.width = 150;
			//oCell.bgColor = "#FFFFFF";
			oCell.bgColor = "#8DBDD3";
			oCell.innerHTML = "<img src='_pics/empty.gif' alt='' width=1 height=1 border=0>";
			
			oRow = oTable.insertRow(-1);
			oRow.id = idPrefix + this.MenuID + "item";
			oRow.bgColor = catColor[this.ColorID].L3Lo;
			oRow.onmouseover = hilite;
			oRow.onmouseout = lolite;
			/*oRow.className = "MenuItem3";
			oCell = oRow.insertCell(-1);
			oCell.id = idPrefix + this.MenuID;
			oCell.width = "13%";
			//oCell.width = 16;
			oCell.vAlign = "top";
			oCell.innerHTML = "<img src='_pics/bullet_gray.gif' alt='' border=0 vspace=6 hspace=12>";*/
			oCell = oRow.insertCell(-1);
//				oCell.id = idPrefix + this.MenuID;
			oCell.width = "100%";
			//oCell.width = 150;
			oCell.className = "MenuItem3";
			oCell.align = "right";
			if (this.URL == "")
//				oCell.innerHTML = "<div style='width:130px;' id='" + idPrefix + this.MenuID + "B' class='MenuItem3A'>" + this.MenuText + "</div>";
				oCell.innerHTML = "<div style='width:130px; color:" + colorLoT + "' id='" + idPrefix + this.MenuID + "' class='MenuItem3A'>" + this.MenuText + "</div>";
			else
//				oCell.innerHTML = "<div style='width:130px;'><a id='" + idPrefix + this.MenuID + "A' class='MenuItem3A' href='" + this.URL + "'>" + this.MenuText + "</a></div>";
				oCell.innerHTML = "<div style='width:130px;'><a style='color:" + colorLoT + "' id='" + idPrefix + this.MenuID + "' class='MenuItem3A' href='" + this.URL + "'>" + this.MenuText + "</a></div>";
			break;
		default :
			break;
	}
}

function MenuObj()
{
	this.Items = new Array();
}

Menu = new MenuObj();

function sortByMenuID(a,b)
{
	//add logic to compare ID with more than one digit
	if (a.MenuID > b.MenuID) {return 1;}
	if (a.MenuID < b.MenuID) {return -1;}
	if (a.MenuID = b.MenuID) {return 0;}
}

var openedItemID = "";
var openedItemIndex = -1;

function showMenu()
{
	var openedItemColorID = 0;
	var fullname = window.location.pathname;
	var barename = fullname.substring("/".length, fullname.length);
//	var barename = fullname.substring("/_20051101/".length, fullname.length);
	
	//document.write("<table id='ROOT' border=0 cellspacing=0 cellpadding=0 width=150></table>");
	pageObj = document.getElementById("showMenu");
	pageObj.innerHTML = "<table id='ROOT' border=0 cellspacing=0 cellpadding=0 width='100%'></table>";
	
	Menu.Items = Menu.Items.sort(sortByMenuID);
	for (i = 0; i < Menu.Items.length; i++)
	{
		if (typeof(Menu.Items[i]) != "undefined")
		{
			Menu.Items[i].drawMenu();
			if (Menu.Items[i].URL == barename)
			{
				openedItemID = Menu.Items[i].MenuID;
				openedItemColorID = Menu.Items[i].ColorID;
				
				openedItemIndex = i;
			}
		}
	}
	if (openedItemID != "") { expandSub(idPrefix + openedItemID, openedItemColorID); }
}

function getColorIDbyMenuID(MenuID)
{
	for (i = 0; i < Menu.Items.length; i++)
	{
		if (typeof(Menu.Items[i]) != "undefined")
		{
			if (Menu.Items[i].MenuID == MenuID)
			{
				return Menu.Items[i].ColorID;
			}
		}
	}
	// if cant find then return default color id 2
	return 2;
}

function expandSub(clickedItemID, ColorID)
{
	/*for (i = 0; i < Menu.Items.length; i++)
	{
		if (typeof(Menu.Items[i]) != "undefined")
		{
			if (Menu.Items[i].Level < 3)
			{
				document.getElementById(idPrefix + Menu.Items[i].MenuID + "sub").style.display = "none";
			}
		}
	}*/
	
	if (idPrefix == clickedItemID) return;
	

	var MenuID = "";
	var colorHi = "#000000";
	//var ColorID = 0;
	//ColorID = getColorIDbyMenuID(MenuID);
	
	levels = clickedItemID.substring(idPrefix.length, clickedItemID.length).split("_");
	//miID = idPrefix;
	for (i = 0; i < levels.length; i++)
	{
		MenuID = MenuID + levels[i];
		
		//ColorID = getColorIDbyMenuID(MenuID);
		
		switch (i + 1)
		{
			case 1 :
//				colorHi = catColor[getColorIDbyMenuID(MenuID)].L1Hi;
				colorHi = catColor[ColorID].L1Hi;
				break;
			case 2 :
//				colorHi = catColor[getColorIDbyMenuID(MenuID)].L2Hi;
				colorHi = catColor[ColorID].L2Hi;
				break;
			case 3 :
//				colorHi = catColor[getColorIDbyMenuID(MenuID)].L3Hi;
				colorHi = catColor[ColorID].L3Hi;
				break;
			default :
				break;
		}

		// if it is last level item, then highlight it
		//if (i == levels.length - 1) {
		// highlight level 0 opened item only
		if (i == 0) {
		currentmi = document.getElementById(idPrefix + MenuID + "item");
		currentmi.bgColor = colorHi;
		currentmi = document.getElementById(idPrefix + MenuID);
//		currentmi.style.color = "#FFFFFF";
		currentmi.style.color = catColor[ColorID].HiT;
		}

		if (i < 2)
		{
			submi = document.getElementById(idPrefix + MenuID + "sub");
			document.getElementById(idPrefix + MenuID + "subcnt").rows.length > 0 ? submi.style.display = "inline" : submi.style.display = "none";
		}
		if (i == 0)
		{
			pageObj = document.getElementById("photo_topleft");
			pageObj.src = "_pics/pk_topleft_" + MenuID + ".gif";
		}
		if (i == 2) break;
		MenuID = MenuID + "_";
	}
}

function hilite()
{
	dolite(this, "hilite");
}

function lolite()
{
	dolite(this, "lolite");
}

function dolite(obj, method)
{
	var ColorID = 0;
	var MenuID = obj.id.substring(idPrefix.length, obj.id.length);
	MenuID = MenuID.substring(0, MenuID.indexOf("item"));
	var foreObj = document.getElementById(idPrefix + MenuID);
	

	var ignore = 1;
	opened = openedItemID.split("_");
	levels = MenuID.split("_");

	for (i = 0; i < levels.length; i++)
	{
		if (opened[i] != levels[i]) { ignore = 0; break; }
	}
	// only keep level 0 opened item hightlighted
	if (ignore == 1 && i == 1) return;

	//if (openedItemID == MenuID) return;
	
	ColorID = getColorIDbyMenuID(MenuID);
	/*for (i = 0; i < catColor.length; i++)
	{
		if (catColor[i].allColor.toUpperCase().indexOf(obj.bgColor.toUpperCase()) >= 0) { ColorID = i; break; }
	}*/
	//alert(catColor[ColorID].allColor + ":" + obj.bgColor + ":" + ColorID);
	switch (levels.length)
	{
		case 1 :
			if (method == "hilite") {obj.bgColor = catColor[ColorID].L1Hi; foreObj.style.color = catColor[ColorID].HiT;} 
//			else {obj.bgColor = catColor[ColorID].L1Lo; foreObj.style.color = colorLoT;}
			else {obj.bgColor = colorL1Init; foreObj.style.color = colorLoT;}
			break;
		case 2 :
			if (method == "hilite") {obj.bgColor = catColor[ColorID].L2Hi; foreObj.style.color = catColor[ColorID].HiT;} else {obj.bgColor = catColor[ColorID].L2Lo; foreObj.style.color = colorLoT;}
			//method == "hilite" ? obj.bgColor = catColor[ColorID].L2Hi : obj.bgColor = catColor[ColorID].L2Lo;
			break;
		case 3 :
			if (method == "hilite") {obj.bgColor = catColor[ColorID].L3Hi; foreObj.style.color = catColor[ColorID].HiT;} else {obj.bgColor = catColor[ColorID].L3Lo; foreObj.style.color = colorLoT;}
			//method == "hilite" ? obj.bgColor = catColor[ColorID].L3Hi : obj.bgColor = catColor[ColorID].L3Lo;
			break;
		default :
			break;
	}
}

function drawPage()
{
	if (openedItemIndex == -1)
	{
		pageObj = document.getElementById("photo_topleft");
		pageObj.src = "_pics/pk_topleft_0.gif";
		return;
	}

	document.title = "DAAD - " + Menu.Items[openedItemIndex].HeadText;
	pageObj = document.getElementById("head_area");
	pageObj.bgColor = catColor[Menu.Items[openedItemIndex].ColorID].Frame;
	pageObj = document.getElementById("content_area");
	pageObj.bgColor = catColor[Menu.Items[openedItemIndex].ColorID].Frame;
	pageObj = document.getElementById("footer_area");
	pageObj.bgColor = catColor[Menu.Items[openedItemIndex].ColorID].Frame;
	
	pageObj = document.getElementById("head_topleft");
	pageObj.src = "_pics/pk_head_topleft_color" + Menu.Items[openedItemIndex].ColorID + ".gif";
	pageObj = document.getElementById("head_text");
	pageObj.innerHTML = Menu.Items[openedItemIndex].HeadText;
	pageObj = document.getElementById("head_home");
	pageObj.src = "_pics/pk_head_home_color" + Menu.Items[openedItemIndex].ColorID + ".gif";
	pageObj = document.getElementById("head_dotline");
	//pageObj.background = "_pics/pk_dotline_colorONcolor_color" + Menu.Items[openedItemIndex].ColorID + ".gif";
	pageObj.style.backgroundImage  = "url(_pics/pk_dotline_colorONcolor_color" + Menu.Items[openedItemIndex].ColorID + ".gif)";
	pageObj = document.getElementById("foot_dotline");
	pageObj.style.backgroundImage = "url(_pics/pk_dotline_whiteONcolor_color" + Menu.Items[openedItemIndex].ColorID + ".gif)";
	pageObj = document.getElementById("cat_color");
	pageObj.href = "_sys/catcolor" + Menu.Items[openedItemIndex].ColorID + ".css";

	/*pageObj = document.getElementById("ft_testdaf");
	pageObj.src = "_pics/pk_ft_partner_testdaf_color" + Menu.Items[openedItemIndex].ColorID + ".gif";
	pageObj = document.getElementById("ft_goethe");
	pageObj.src = "_pics/pk_ft_partner_goethe_color" + Menu.Items[openedItemIndex].ColorID + ".gif";*/
	
}

function initPage()
{
	showMenu();
	drawPage();
	//document.styleSheets[0].href = "styles1.css";
}
//alert(document.styleSheets.length);
/*
for ( i = 0; i < document.styleSheets.length; i++ )
{
alert("Style sheet " + i + " is titled " + document.styleSheets(i).href);
}
*/
//document.styleSheets("daad_css").href = "styles1.css";

function AddF()
{
	window.external.AddFavorite(location.href, document.title);
}

function PrintF()
{
	newwin = window.open('_sys/print.htm', 'print', 'width=680,height=610,menubar=0,resizable=0,location=0,status=0,directories=0,scrollbars=1' );
}

function drawMap()
{
	switch (this.Level)
	{
		case 1 :
			oUL = document.getElementById("root_ul");
			oLI = document.createElement("li");
			oUL.appendChild(oLI);
			if (this.URL == "")
				//oLI.innerHTML = "<span id='" + idPrefix + this.MenuID + "'>" + this.HeadText + "</span>";
				oLI.innerHTML = this.HeadText;
			else
				//oLI.innerHTML = "<a id='" + idPrefix + this.MenuID + "' href='" + this.URL + "'>" + this.HeadText + "</a>";
				oLI.innerHTML = "<a href='" + this.URL + "'>" + this.HeadText + "</a>";
			
			oLI.innerHTML = oLI.innerHTML + "<ul id='" + idPrefix + this.MenuID + "_ul'></ul>";
			break;
		case 2 :
			var upperMenuID = this.MenuID.substring(0, this.MenuID.lastIndexOf("_"));
			oUL = document.getElementById(idPrefix + upperMenuID + "_ul");
			oLI = document.createElement("li");
			oUL.appendChild(oLI);
			if (this.URL == "")
				//oLI.innerHTML = "<span id='" + idPrefix + this.MenuID + "'>" + this.HeadText + "</span>";
				oLI.innerHTML = this.HeadText;
			else
				//oLI.innerHTML = "<a id='" + idPrefix + this.MenuID + "' href='" + this.URL + "'>" + this.HeadText + "</a>";
				oLI.innerHTML = "<a href='" + this.URL + "'>" + this.HeadText + "</a>";
				
			oLI.innerHTML = oLI.innerHTML + "<ul id='" + idPrefix + this.MenuID + "_ul'></ul>";
			break;
		case 3 :
			var upperMenuID = this.MenuID.substring(0, this.MenuID.lastIndexOf("_"));
			oUL = document.getElementById(idPrefix + upperMenuID + "_ul");
			oLI = document.createElement("li");
			oUL.appendChild(oLI);
			if (this.URL == "")
				//oLI.innerHTML = "<span id='" + idPrefix + this.MenuID + "'>" + this.HeadText + "</span>";
				oLI.innerHTML = this.HeadText;
			else
				//oLI.innerHTML = "<a id='" + idPrefix + this.MenuID + "' href='" + this.URL + "'>" + this.HeadText + "</a>";
				oLI.innerHTML = "<a href='" + this.URL + "'>" + this.HeadText + "</a>";
				
			//oLI.innerHTML = "<ul id='" + idPrefix + this.MenuID + "_ul'>" + oLI.innerHTML + "</ul>";
			break;
		default :
			break;
	}
}

function showMap()
{
	pageObj = document.getElementById("showMap");
	pageObj.innerHTML = "<ul class='normText11px' id='root_ul'></ul>";
	
	Menu.Items = Menu.Items.sort(sortByMenuID);
	for (i = 0; i < Menu.Items.length; i++)
	{
		if (typeof(Menu.Items[i]) != "undefined")
		{
			Menu.Items[i].drawMap();
		}
	}
}

function resizeNews(newsIFrame)
{
	newsIFrame.height = newsIFrame.contentWindow.document.body.scrollHeight + 20;
}
