Element.prototype.findEntry = findEntry;
Element.prototype.show = show;
Element.prototype.showtree = showtree;
Element.prototype.expandEntry = expandEntry;
Element.prototype.expandSection = expandSection;
Element.prototype.expandPath = expandPath;
Element.prototype.expandPath2 = expandPath2;

var localdoc = document;
var localclass = "";
var tableWidth = 170;
var localwin = window;
var interations = 0;

var ns4=document.layers?1:0;
var ie4=document.all?1:0;
var ns6=document.getElementById&&!document.all?1:0;

function Element(name, number, path)
{
	this.name = name.first("|");

	this.child = null;
	this.next = null;
	this.expand = 0;
	this.secure = 0;
	this.url = name.rest("|");
	this.target = this.url.word("#", 2);
	if(this.target != "")
	{
		if(this.url.word("#", 3) == "S")
			this.secure = 1;
		this.url = this.url.first("#");
	}

	this.number = number;
	if(this.url == "")
		this.path = path;
	else
	{
		var p = path.lastIndexOf("->");
		if(p == -1)
			this.path = "";
		else
			this.path = path.substring(0, p);
	}
	var nav = navinfo.quickFind(this.path, "|");

	if(nav != "")
	{
		this.center = nav.word("|", 3);
		this.newscat = nav.word("|", 4);
		if(this.url == "")
			this.status = nav.word("|", 2).replace(/'/, "&#8217;");
		else
			this.status = this.name.replace(/'/, "&#8217;");
	}
	else
	{
		this.status = this.name.replace(/'/, "&#8217;");
		this.center = "";
		this.newscat = newsCategory;
	}
}

function findEntry(number)
{
	var entry = null;
	if(this.number == number)
		return(this);
	if(this.child != null)
		entry = this.child.findEntry(number);
	if(entry != null)
		return(entry);
	if(this.next != null)
		entry = this.next.findEntry(number);
	return(entry);
}

function loadCenter(entry)
{
	if(entry.center != "")
	{
		var w = self;
		var hops = 0;
		for(hops = 0; !w.KISTERS_CENTER & hops < 10; hops++)
		{
			w = w.parent;
		}
		if(hops != 10)
			if(w.KISTERS_CENTER)
			{
				var center;
				if(entry.center.toLowerCase().indexOf("&newscategory=") == -1 && entry.newscat != "")
					center = entry.center + "&NewsCategory=" + entry.newscat;
				else
					center = entry.center;
				var c = center.replace(/\//g, "\\/");
				c = c.replace(/\?/g, "\\?");
				w.KISTERS_CENTER.location.href = center;
			}
	}
}

function expandEntry(number)
{
	var entry = this.findEntry(number);
	if(entry != null)
	{
		entry.expand = !entry.expand;

		if(entry.expand == true)
			loadCenter(entry);
	}
}

function Loading_verstecken()
{
	if(navigator.family == 'nn4')
		document.LoadPageMessage.visibility="hidden";
	else
		LoadPageMessage.style.visibility="hidden";
}
function expandSection(number, win)
{
	if(navigator.DOMCSS1 || navigator.family == 'ie4' || navigator.family == 'opera')
	{
		var s1 = win.document.getElementById("entry" + number).style;

		var ele = win.document.getElementById("a" + number);
		var img = win.document.createAttribute("src");
		if(s1.display == 'none')
		{
			s1.display = 'block';
			img.nodeValue=thisWebName + "springfill_menu_open.gif";
			ele.setAttributeNode(img);
			var entry = this.findEntry(number);
			if(entry != null)
				loadCenter(entry);
		}
		else
		{
			img.nodeValue=thisWebName + "springfill_menu_close.gif";
			ele.setAttributeNode(img);
			s1.display = 'none';
		}
	}
	else
	{
		this.expandEntry(number);
		win.location.reload();
	}
}

function show(doc, _class)
{
	localdoc = doc;
	localclass = _class;
/*
	var obj = localdoc.getElementsByName("_leftnavmiddle")[0];
	var element=localdoc.createElement("table");
	var attr = localdoc.createAttribute("cellspacing");
	attr.nodeValue="0";
	element.setAttributeNode(attr);
	attr = localdoc.createAttribute("cellpadding");
	attr.nodeValue = "0";
	element.setAttributeNode(attr);
	attr = localdoc.createAttribute("width");
	attr.nodeValue = "95%";
	element.setAttributeNode(attr);
	attr = localdoc.createAttribute("onMouseOver");
	attr.nodeValue = "resetEntry();";
	element.setAttributeNode(attr);
	obj.appendChild(element);
*/
	doc.writeln('<table style="overflow:hidden;" class="color" cellspacing=0 cellpadding=0 width=100% onMouseOver="resetEntry();"');
	this.showtree(_class);
	doc.writeln("</table>");
}

function createURL(entry)
{
	var pos = entry.indexOf("#");
	var url = (pos < 0) ? entry : entry.substring(0, pos);
	
	if(url.indexOf("file:") == 0)
		return(url);
	if(isUNID(url.substr(0, 32)))
		url = "0/" + url.substr(0, 32);
	if(url.indexOf("http:") == 0)
		url = url.substring(5);
	if(url.indexOf("//") != 0 && url.indexOf("/") != 0)
		url = thisWebName + url;
	if(url.indexOf("//") != 0 && url.indexOf("/") == 0)
		url = "//" + location.hostname + url;
	return("http:" + url);
}
function isUNID(entry)
{
	if(entry.match(/\w+/) == entry)
		return(true);
	return(false);
}
function showtree(_class)
{
	localdoc.write("<tr>");
	if(this.url != "")
	{
		var newsCategory = (this.newscat != "") ? "&NewsCategory=" + this.newscat : "";
		var url = (this.target != "") ? createURL(this.url) : createURL(this.url) + "!Open" + newsCategory;
		var target = (this.target != "") ? this.target : "KISTERS_CENTER";
		if(navigator.DOMCSS1 || navigator.family == 'opera')
		{
			localdoc.write("<td onmouseout=\"status=''; return true;\" onmouseover=\"status='" + this.status + "';return true;\">");
			localdoc.write("<a class=\"" + _class + (this.high==true ? "\" id=\"high":"") + "\" href=\"" + url + "\" target=\"" + target + "\">");
			if(this.secure)
				localdoc.write(this.name + "<img hspace=5 border=0 src=\"/library.nsf/Images/ServiceImages/$file/key.gif\" width=14 height=9 alt=\"\">");
			else
				localdoc.write(this.name);
			localdoc.write("</a>");
		}
		else
		{
			localdoc.writeln("<td>");
			localdoc.write("<a class=\'" + _class +  "\'");
			localdoc.write(" onmouseout=\"status=''; return true;\" onmouseover=\"status='" + this.status + "'; return true;\" href='" + url + "' target='" + target + "'>");
			if(this.secure)
				localdoc.write(this.name + "<img hspace=5 border=0 src=\"/library.nsf/Images/ServiceImages/$file/key.gif\" width=14 height=9 alt=\"\">");
			else
				localdoc.write(this.name);
			localdoc.writeln("</a>");
		}
	}
	else
	{
		if(navigator.DOMCSS1 || navigator.family == 'opera')
		{
			localdoc.write("<td onmouseout=\"status=''; return true;\" onmouseover=\"status='" + this.status + "';return true;\">");
			localdoc.write("<a class=\"" + _class + "\" href=\"javascript:tree.expandSection('" + this.number + "', window);\">");
			localdoc.write("<img hspace=0 align=left id=\"a" + this.number + "\" border=0 src=\"" + thisWebName + (this.expand?"springfill_menu_open.gif":"springfill_menu_close.gif") + "\" width=12 height=12 alt=\"\">");
			localdoc.write(this.name);
			localdoc.write("</a>");
		}
		else
		{
			localdoc.writeln("<td valign=center width=200");
			localdoc.write("><a class='" + _class + "' href=\"javascript: tree.expandSection('" + this.number + "', window);\">");
			if(this.expand == true)
				localdoc.write("<img hspace=0 align=left border=0 src=\"" + thisWebName + "springfill_menu_open.gif\" width=12 height=12 alt=\"\">");
			else
				localdoc.write("<img hspace=0 align=left border=0 src=\"" + thisWebName + "springfill_menu_close.gif\" width=12 height=12 alt=\"\">");
			localdoc.write(this.name);
			localdoc.writeln("</a>");
		}
	}
	localdoc.writeln("</td></tr>");

	if((navigator.DOMCSS1 || this.expand == true || navigator.family == 'opera') && this.child != null)
	{
		if(navigator.DOMCSS1 || navigator.family == 'opera')
		{
			localdoc.write("<tr><td>");
			localdoc.write("<div class=\"indent\" style=\"display:" + (this.expand ? "block":"none") + "\" id=\"entry" + this.number + "\">");
			localdoc.write("<table class=\"color\" border=0 cellspacing=0 cellpadding=0>");
		}
		else
		{
			localdoc.writeln("<tr><td class=menu width=100%><div>");
			localdoc.writeln("<table class=\"menu\" border=0 cellspacing=0 cellpadding=0>");
		}

		this.child.showtree(_class);
		localdoc.writeln("</table></div></td></tr>");
	}

	if(this.next != null)
		this.next.showtree(_class);
}

function addEntry(e1, e2)
{
	iterations = 0;
	 var path = "";
	var number = "1";
	var first = e1;
	ret = addEntry1(e1, e2, number, path);
	return(first == null ? ret : first);
}
function addEntry1(e1, e2, number, path)
{
	if(e2 == "")
		return(e1);

	var name1 = e2.first("->");
	var name2 = e2.rest("->");
	var newpath = (path == "") ? name1 : path + "->" + name1;
	var e3 = null;
	var pos = number.lastIndexOf(".");
	var n = Number(number.slice(pos + 1));

	 while(e1 != null)
	 {
		if(e1.name == name1)
		{
			return(addEntry1(e1.child, name2, e1.number + ".1", newpath));
		}
		e3 = e1;
		n = n + 1;
		e1 = e1.next;
	 }
	number = (pos == -1 ? n: number.substring(0, pos) + "." + n);
	e1 = new Element(name1, number, newpath);
	if(e3 != null)
		e3.next = e1;
	if(name2 != "")
		e1.child = addEntry1(e1.child, name2, e1.number + ".1", newpath);
	return(e1);
}
var obj;
function expandPath()
{
	if(top.KISTERS_MAIN)
		if(top.KISTERS_MAIN.KISTERS_CENTER)
		{
			obj = top.KISTERS_MAIN.KISTERS_CENTER;
			if(obj.NavPath)
			{
				this.expandPath2(obj.NavPath);
				return(true);
			}
			else
				return(highlightEntry(this));
		}
		else
			if(top.KISTERS_CENTER)
			{
				obj = top.KISTERS_CENTER;
				if(obj.NavPath)
				{
					this.expandPath2(obj.NavPath);
					return(true);
				}
				else
					return(false);
			}
	return(true);
}
function expandPath2(path)
{
	var name1 = path.first("->");
	var name2 = path.rest("->");
	var e1 = this;
	while(e1 != null)
	{
		if(e1.name == name1)
		{
			e1.expand = true;
			if(e1.child != null)
				if(name2 != "")
					return(e1.child.expandPath2(name2));
				else
					return(highlightEntry(e1.child));
			return;
		}
		e1 = e1.next;
	}
	return(false);
}
function highlightEntry(e1)
{
	if(obj.NavTitle)
	{
		while(e1!=null)
		{
			if(e1.name==obj.NavTitle && e1.high!=true)
			{
				e1.high=true;
				return(true);
			}
			e1=e1.next;
		}
	}
	return(false);
}
function resetEntry()
{
	if(!navigator.DOMHTML && navigator.family != 'opera')
		style=document.all["high"];
	else
		style=document.getElementById("high");
	if(style)
		style.id="";
}

