var open = selected ? (menu[selected-1]["parent"] != 0 ? menu[selected-1]["parent"] : menu[selected-1]["id"]) : 0;


document.writeln('<table cellpadding="0" cellspacing="0" border="0" width="216">');
z = 1;
	var isOpen=false;
for(i=0;i<=menu.length;i++){
   eval("navi"+i+"On=new Image();navi"+i+"On.src='/images/kasten_over.gif';navi"+i+"Off=new Image();navi"+i+"Off.src='/images/kasten.gif';");
}

for(i=0;i<menu.length;i++){

var link = menu[i]["link"].replace(/.*href="([^"]+)"[^>]*>.*<\/a>/,"$1");
var text = menu[i]["link"].replace(/.*href="[^"]+"[^>]*>(.*)<\/a>/,"$1");
	
	if(open && menu[i]["id"] == open+1 && (i<(menu.length -1) && menu[i+1]["parent"]==open)){
                                document.writeln('<tr height="1">');
		document.writeln('	<td height="1" width="14"></td>');
		document.writeln('	<td width="1" height="1"></td>');
	                document.writeln('	<td height="1" bgcolor="white"><img src="/images/pixel.gif" width="5" height="1" border="0"></td>');
		document.writeln('	<td height="1" bgcolor="white"><img src="/images/pixel.gif" width="196" height="1" border="0"></td>');

		document.writeln('</tr>');
		document.writeln('<tr height="1">');
		document.writeln('	<td height="1" width="14"></td>');
		document.writeln('	<td width="1" height="1"></td>');
		document.writeln('	<td height="1" colspan="2" >');
		
		document.writeln('<table border="0" cellpadding="0" cellspacing="0" width="200" bgcolor="#e9f0e8">');
		isOpen=true;
	}else if(isOpen && menu[i]["parent"] != open){
		document.writeln('</table>');
		document.writeln('</td>');
		document.writeln('</tr>');
		isOpen=false;
}
	if(isOpen){
		document.writeln('<tr height="14">');
		document.writeln('<td height="14" ID="box'+(i+1)+'" width="5"'+((menu[i]["id"] == selected) ? 'bgcolor="#dd0000"' : '')+'><img src="/images/pixel.gif" width="7" height="14" border="0" name="navi'+(i+1)+'"></td>');
		document.writeln('<td height="14" width="5"><img src="/images/pixel.gif" width="3" height="1" border="0"></td>');
		document.writeln('<td height="14" width="190"><a  href="'+link+'"'+((menu[i]["id"] != selected) ? ' OnMouseOver="change(\'navi'+(i+1)+'\',\'1\')" OnMouseOut="change(\'navi'+(i+1)+'\',\'0\')"' : '')+'>'+((menu[i]["id"] == selected) ? '<font color="#dd0000">' : '')+text+((menu[i]["id"] == selected) ? '</font>' : '')+'</a></td>');
		document.writeln('</tr>');

	}else if(menu[i]["parent"]==0){	
	
		document.writeln('<tr height="1">');
		document.writeln('	<td height="1" width="14"></td>');
		document.writeln('	<td width="1" height="1"></td>');
	                document.writeln('	<td height="1" bgcolor="white"><img src="/images/pixel.gif" width="5" height="1" border="0"></td>');
		document.writeln('	<td height="1" bgcolor="white"><img src="/images/pixel.gif" width="196" height="1" border="0"></td>');
	 	document.writeln('</tr>');

		document.writeln('<tr height="14">');
		document.writeln('	<td width="14" '+((menu[i]["id"] == open) ? ' bgcolor="#dd0000"' : ' bgcolor="#b9c7b9"')+' height="14" id="box'+(i+1)+'"><img src="/images/pixel.gif" width="14" height="14" border="0" name="navi'+(i+1)+'"></td>');
		document.writeln('	<td width="1" height="1"><img src="/images/pixel.gif" width="1" height="1"></td>');
		document.writeln('	<td width="5" height="14" bgcolor="'+((menu[i]["id"] == open) ? '#d0e1d1' : '#deeade')+'"><img src="/images/pixel.gif" width="5" height="1" border="0"></td>');
		document.writeln('	<td height="14" bgcolor="'+((menu[i]["id"] == open) ? '#d0e1d1' : '#deeade')+'"><a  href="'+link+'"'+((menu[i]["id"] != open) ? ' OnMouseOver="change(\'navi'+(i+1)+'\',\'1\')" OnMouseOut="change(\'navi'+(i+1)+'\',\'0\')"' : '')+'>'+((menu[i]["id"] == open) ? '<font color="#336633"><b>' : '')+text+((menu[i]["id"] == open) ? '</font></b>' : '')+'</a></td>');
		document.writeln('</tr>');
   	}	
}
if(isOpen){
		document.writeln('</table>');
		document.writeln('</td>');
		document.writeln('</tr>');
		isOpen=false;

}

document.writeln('<tr height="1">');
document.writeln('	<td height="1" width="14"></td>');
document.writeln('	<td width="1" height="1"></td>');
document.writeln('	<td height="1" bgcolor="white"></td>');
document.writeln('	<td height="1" bgcolor="white"></td>');
document.writeln('</tr>');
document.writeln('</table>');




