// adapted from
// 
// = = ================================================================================ = =
// = =  Sliding Menu v1.0                (c) 2004 Triple-M / http://www.htmlarsenal.de  = =
// = = ================================================================================ = =
// 
// ----------------------------------------------------------------------------------------
// -- Dieses Script und viele andere im                                                  --
// -- This script and many more in the                                                   --
// ----------------------------------------------------------------------------------------
// -- HTML ARSENAL - Die Quelle für HTML, JavaScript, PHP                                --
// -- HTML ARSENAL - Your Source for HTML, JavaScript, PHP                               --
// ----------------------------------------------------------------------------------------
// --                                                   -= http://www.htmlarsenal.de =-  --
// ----------------------------------------------------------------------------------------
// 
// Sie dürfen dieses Script für nicht-kommerzielle Zwecke nutzen, wenn diese Urheber-Notiz erhalten bleibt.
// You may use this Script for non-commercial causes as long as you include this copyright notice.

var to=0;

function foldout(mid,akt,height,current) {
	current+=5;
	document.getElementById(mid+'_b'+akt).style.height=current+"px";
	if (current<height) {
		to=window.setTimeout('foldout("'+mid+'",'+akt+','+height+','+current+')',50);
	} else {
		to=0;
	}
}

function asmtoggle(mid,akt,height,num_head) {
	var i;
	if (to) {
		window.clearTimeout(to);
	}
	if (parseInt(document.getElementById(mid+'_b'+akt).style.height)>1) {
		for (i=0;i<num_head;i++) {
			document.getElementById(mid+'_b'+i).style.height="1px";
		}
	} else {
		for (i=0;i<num_head;i++) {
			document.getElementById(mid+'_b'+i).style.height="1px";
		}
		foldout(mid,akt,height,0);
	}
}

function menu() {
	if(menu.arguments.length==0) {
		alert("zero menu items");
	}
	var mid="asm"+Math.floor(Math.random()*1000);
	var num_head=parseInt(menu.arguments[0]);
	var i,j;
	var akt=1;
	var head=new Array(num_head);
	var num,height,columns,column;
	for (i=0;i<num_head;i++) {
		head[i]=menu.arguments[akt++];
	}
	for (i=0;i<num_head;i++) {
		num=menu.arguments[akt++];
		/*height=menu.arguments[akt++];*/
		columns=menu.arguments[akt++];
		if (columns>1) {
			height=Math.floor(num/columns)*15;
			if (num % columns > 0) {
				height+=15;
			}
		} else {
			height=num*15;
		}
		document.writeln('<div class="asmhead" id="'+mid+'_h'+i+'" onClick="asmtoggle(\''+mid+'\','+i+','+height+','+num_head+')">');
		document.writeln('<a name="menue'+i+'" title="click to expand or collapse menue">'+head[i]+'</a>');
// 		document.writeln(head[i]);
		document.writeln('<\/div>');
		if (columns>1) {
			column=0;
		}
		document.writeln('<nobr><div class="asmbody" id="'+mid+'_b'+i+'">');
		for(j=0;j<num;j++) {
			if (columns>1) {
				column++;
				document.writeln('<div style="float: left; width: 20px; text-align: center">');
			}
			var url  = menu.arguments[akt+1];
			if (url != "") {
				var title = menu.arguments[akt+2];
				if (title != "") {
					title=' title="'+title+'"';
				}
				target = ' target="_parent"';
				if (url.substr(0,1)=='@') { url = url.substr(1); target = ' target="_blank"'; }
				document.writeln('<a href="'+url+'"'+target+title+'>'+menu.arguments[akt]+'<\/a>');
			} else {
				document.writeln(menu.arguments[akt]);
			}
			if (columns>1) {
				document.writeln('<\/div>');
				if (column == columns || j == (num-1)) {
					column = 0;
					document.writeln('<\/br>');
				}
			} else {
				document.writeln('<\/br>');
			}
			akt+=3;
		}
		document.writeln('<\/div></nobr>');
	}
}
