//*************************************************

var NewWindow;

// Menu Aufbau DIV generierung **************************



function GenerateMenu() {
	if (document.layers) {
						document.writeln('<style type="text/css">');
						document.writeln('a:link { text-decoration:none; font-family:sans-serif; color:#000000; }');
						document.writeln('a:visited { text-decoration:none; font-family:sans-serif; color:#000000; }');
						document.writeln('a:hover { text-decoration:none; font-family:sans-serif; color:#000000; }');
						document.writeln('a:active { text-decoration:none; font-family:sans-serif; color:#000000; }');
						document.writeln('</style>');

				document.writeln('<BR><table border="0" cellpadding="0" cellspacing="2">');

				for (var i=0; i < HauptMenus.length; i++) {
						if (HauptMenus[i]["LINK"] != "") {
							if ( HauptMenus[i]["TARGET"] == "_new" || HauptMenus[i]["TARGET"] == "" ) {
								LinkTarget = "_new"
							} else {
								LinkTarget = HauptMenus[i]['TARGET'];
							}
						}
					document.writeln('<tr><td bgcolor="#f1f1f1">');
					document.writeln('&nbsp;<font size="3"><a href="'+HauptMenus[i]['LINK']+'" target="'+LinkTarget+'">'+HauptMenus[i]["TEXT"]+'</a></font>&nbsp;');
					document.writeln('</td></tr>');

					for (var j=0; j < UnterMenus.length; j++) {
						if (UnterMenus[j]["ID"].search(HauptMenus[i]["ID"]) != -1) {
							if (UnterMenus[j]["LINK"] != "") {
								if ( UnterMenus[j]["TARGET"] == "_new" || UnterMenus[j]["TARGET"] == "" ) {
									LinkTarget = "_new"
								} else {
									LinkTarget = UnterMenus[j]['TARGET'];
								}
							}
							document.writeln('<tr><td bgcolor="#fafafa">');
							document.writeln('&nbsp;&nbsp;&nbsp;&nbsp;<font size="2"><a href="'+UnterMenus[j]['LINK']+'" target="'+LinkTarget+'">'+UnterMenus[j]["TEXT"]+'</a></font>&nbsp;');
							document.writeln('</td></tr>');
						}
					}
				}
				document.writeln('</table>');

	} else {
	for (var i=0; i < HauptMenus.length; i++) {
		document.writeln('<div id='+HauptMenus[i]["ID"]+' style="position:relative; left:0px; top:'+MENU_pos_top+'px" class="MainMenu" onClick="ClickMainMenu(this.id);" onMouseOver="OverMainMenu(this.id);" onMouseOut="OutMainMenu(this.id);">');
		document.writeln(HauptMenus[i]["TEXT"]);
		document.writeln('</div>');
	}
	}
}

function GenerateMenuUMString() {
	if (document.layers) {
		var UmString = "";
		return UmString;
	} else {
	var UmString = "";
	for (var i=0; i < HauptMenus.length; i++) {

		for (var j=0; j < UnterMenus.length; j++) {
			if (UnterMenus[j]["ID"].search(HauptMenus[i]["ID"]) != -1) {
				UmString += '<div id='+UnterMenus[j]["ID"]+' style="position:relative; left:0px; top:0px; display:none" class="SubMenu" onClick="parent.menu.ClickSubMenu(this.id);" onMouseOver="parent.menu.OverSubMenu(this.id);" onMouseOut="parent.menu.OutSubMenu(this.id);">';
				UmString += UnterMenus[j]["TEXT"];
				UmString += '</div>'+'\n';
			}
		}
	}
	return UmString;
	}
}

// ************************************************************

function ClearAll() {
	for (var i=0; i < UnterMenus.length; i++) {
            if(parent.topmenu.document.getElementById(UnterMenus[i]["ID"]) != null){
          	parent.topmenu.document.getElementById(UnterMenus[i]["ID"]).style.display="none";
		for (var k=0; k < SubEventStyle.length; k++) {
			if ( SubEventStyle[k]["VALUE"]["normal"] != "" ) {
				eval("parent.topmenu.document.getElementById('"+UnterMenus[i]['ID']+"').style."+SubEventStyle[k]["NAME"]+" = '"+SubEventStyle[k]["VALUE"]["normal"]+"'");
			}
		}
            }
	}
	for (var i=0; i < HauptMenus.length; i++) {
		for (var k=0; k < MainEventStyle.length; k++) {
			if ( MainEventStyle[k]["VALUE"]["normal"] != "" ) {
				eval("document.getElementById('"+HauptMenus[i]['ID']+"').style."+MainEventStyle[k]["NAME"]+" = '"+MainEventStyle[k]["VALUE"]["normal"]+"'");
			}
		}
	}
}

function ExpandAll() {
	ClearAll();
	for (var i=0; i < UnterMenus.length; i++) {
		parent.topmenu.document.getElementById(UnterMenus[i]["ID"]).style.display="inline";
	}
}

function ExpandFirst() {
	ClearAll();
	ClickMainMenu('m0');
	for (var i=0; i < UnterMenus.length; i++) {
		if ( UnterMenus[i]["ID"].slice(0,2) == "m0" ) {
                    if(parent.topmenu.document.getElementById(UnterMenus[i]["ID"]) != null){
			parent.topmenu.document.getElementById(UnterMenus[i]["ID"]).style.display="inline";
                    }
		}
	}
	ClickSubMenu('m0_0');
}

function ExpandLink(link_id) {
	if (link_id.length > 2) {
			var main_id = link_id.slice(0,eval(link_id.length-2));
			ClickMainMenu(main_id);
			ClickSubMenu(link_id);
	} else {
		ClickMainMenu(link_id);
	}
}



var MainTempClick = new Array();

function ClickMainMenu(id) {
	ClearAll();
	for (var i=0; i < UnterMenus.length; i++) {
		if ( UnterMenus[i]["ID"].search(id) != -1) {
			if(parent.topmenu.document.getElementById(UnterMenus[i]["ID"]) != null){
                          parent.topmenu.document.getElementById(UnterMenus[i]["ID"]).style.display="inline";
                        }
		}
	}
	for (var k=0; k < MainEventStyle.length; k++) {
			MainTempClick[k] = id;
		if ( MainEventStyle[k]["VALUE"]["click"] != "" ) {
			eval("document.getElementById('"+id+"').style."+MainEventStyle[k]["NAME"]+" = '"+MainEventStyle[k]["VALUE"]["click"]+"'");
		}
	}
	for (var j=0; j < HauptMenus.length; j++) {
		if ( HauptMenus[j]["ID"].search(id) != -1) {
			if (HauptMenus[j]["LINK"] != "") {
				if ( HauptMenus[j]["TARGET"] == "_new" || HauptMenus[j]["TARGET"] == "" ) {
					eval("NewWindow = window.open('"+HauptMenus[j]['LINK']+"')");
				} else {
					parent.document.getElementById(HauptMenus[j]['TARGET']).src = HauptMenus[j]['LINK'];
					//eval("parent."+HauptMenus[j]['TARGET']+".location.href = '"+HauptMenus[j]['LINK']+"'");
				}
			}
		}
	}
}

var SubTempClick = new Array();

function ClickSubMenu(um_id) {
	var id = um_id.slice(0,eval(um_id.length-1));
	for (var i=0; i < UnterMenus.length; i++) {
		if ( UnterMenus[i]["ID"].search(id) != -1) {
			for (var k=0; k < SubEventStyle.length; k++) {
				if ( SubEventStyle[k]["VALUE"]["normal"] != "" ) {
                                    if(parent.topmenu.document.getElementById(UnterMenus[i]["ID"]) != null){
					eval("parent.topmenu.document.getElementById('"+UnterMenus[i]['ID']+"').style."+SubEventStyle[k]["NAME"]+" = '"+SubEventStyle[k]["VALUE"]["normal"]+"'");
                                    }
				}
			}
		}
	}
	for (var k=0; k < SubEventStyle.length; k++) {
		SubTempClick[k] = um_id;
		if ( SubEventStyle[k]["VALUE"]["click"] != "" ) {
                    if(parent.topmenu.document.getElementById(um_id) != null){
			eval("parent.topmenu.document.getElementById('"+um_id+"').style."+SubEventStyle[k]["NAME"]+" = '"+SubEventStyle[k]["VALUE"]["click"]+"'");
                    }
		}
	}
	for (var j=0; j < UnterMenus.length; j++) {
		if ( UnterMenus[j]["ID"].search(um_id) != -1) {
			if (UnterMenus[j]["LINK"] != "") {
				if ( UnterMenus[j]["TARGET"] == "_new" || UnterMenus[j]["TARGET"] == "" ) {
					eval("NewWindow = window.open('"+UnterMenus[j]['LINK']+"')");
				} else {
					eval("parent."+UnterMenus[j]['TARGET']+".location.href = '"+UnterMenus[j]['LINK']+"'");
				}
			}
		}
	}
}

function OverMainMenu(id) {
	for (var k=0; k < MainEventStyle.length; k++) {
		if ( (MainTempClick[k] != id) || MainTempClick[k] == null   ) {
			if ( MainEventStyle[k]["VALUE"]["over"] != "" ) {
				eval("document.getElementById('"+id+"').style."+MainEventStyle[k]["NAME"]+" = '"+MainEventStyle[k]["VALUE"]["over"]+"'");
			}
		}
		if (MainTempClick[k] == id && MainEventStyle[k]["VALUE"]["click"] == "") {
			MainTempClick[k] = null;
		}
	}
}

function OverSubMenu(id) {
	for (var k=0; k < SubEventStyle.length; k++) {
		if ( (SubTempClick[k] != id) || SubTempClick[k] == null   ) {
			if ( SubEventStyle[k]["VALUE"]["over"] != "" ) {
				eval("parent.topmenu.document.getElementById('"+id+"').style."+SubEventStyle[k]["NAME"]+" = '"+SubEventStyle[k]["VALUE"]["over"]+"'");
			}
		}
		if (SubTempClick[k] == id && SubEventStyle[k]["VALUE"]["click"] == "") {
			SubTempClick[k] = null;
		}
	}
}


function OutMainMenu(id) {
	for (var k=0; k < MainEventStyle.length; k++) {
		if ( (MainTempClick[k] != id) || MainTempClick[k] == null   ) {
			if ( MainEventStyle[k]["VALUE"]["out"] != "" ) {
				eval("document.getElementById('"+id+"').style."+MainEventStyle[k]["NAME"]+" = '"+MainEventStyle[k]["VALUE"]["out"]+"'");
			}
		}
		if (MainTempClick[k] == id && MainEventStyle[k]["VALUE"]["click"] == "") {
			MainTempClick[k] = null;
		}
	}
}

function OutSubMenu(id) {
	for (var k=0; k < SubEventStyle.length; k++) {
		if ( (SubTempClick[k] != id) || SubTempClick[k] == null   ) {
			if ( SubEventStyle[k]["VALUE"]["out"] != "" ) {
				eval("parent.topmenu.document.getElementById('"+id+"').style."+SubEventStyle[k]["NAME"]+" = '"+SubEventStyle[k]["VALUE"]["out"]+"'");
			}
		}
		if (SubTempClick[k] == id && SubEventStyle[k]["VALUE"]["click"] == "") {
			SubTempClick[k] = null;
		}
	}
}