  var height = 18; // height of the menu headers
  var iheight = 15; // height of the menu_items
  
  var bgc = "lightyellow"; // background color of the item
  var tc = "#333399"; // text color of the item
  var fw = "bold";
    
  var over_bgc = "silver";
  var over_tc = "#FF0000";
  var over_fw = "bold";
  
  var speed = 1;
  var timerID = "";
  var N = (document.all) ? 0 : 1;
  var menuewidth = 149;
  var self_menu = new Array();
  var hasChilds = false;
  var debug = false;
  var debuglevel = 1;
  var tmp_alerts = "";
  var toPullDownNr = "";
  var toPullDownC = "";  

function setFrameSrc (theFrame, src) {
	if (theFrame=="mainFrame") {
		PAGELASTVISITED=src;
		document.getElementById("_lastPageVisited").value=src;
	}
	tmpFrame = eval("top.parent."+theFrame);
	tmpFrame.location.href=src;
}

function color(obj){
	document.getElementById(obj).style.backgroundColor = over_bgc;
	document.getElementById(obj).style.fontWeight  = over_fw;
	document.getElementById(obj).style.color = over_tc;
}

function uncolor(obj){
	document.getElementById(obj).style.backgroundColor = bgc;
	document.getElementById(obj).style.fontWeight = fw;
	document.getElementById(obj).style.color = tc
}

function pullUpAndShowMain (obj,mainlink) {
	toPullDownNr = -1;
	toPullDownC = -1;  
	var _lmotmp = getLastMenuOpened();
    if (_lmotmp[0]!=-1 && _lmotmp[1]!=-1) {	
		document.getElementById("down"+obj).style.background="#7ADEBD";
		single_pull_down(_lmotmp[0],_lmotmp[1]);
	}  else if (_lmotmp[0]!=-1 && _lmotmp[1]==-1) {
		// check if 'single' menue was opened before
		document.getElementById("down"+_lmotmp[0]).style.background="#33CC99";
		document.getElementById("down"+obj).style.background="#7ADEBD";
	}
	top.document.getElementById("mainFrame").src	= mainlink;	
	setLastMenuOpened(obj,-1);
}

function pull_down(nr,c) {
//alert ("pull down called with " + nr + ";" + c);
	var _lmotmp = getLastMenuOpened();
    if (_lmotmp[0]!=-1 && _lmotmp[1]!=-1 && _lmotmp[0]!=nr && _lmotmp[1]!=c) {
		toPullDownNr = nr;
		toPullDownC = c;  
		single_pull_down(_lmotmp[0],_lmotmp[1]);
	} else if (_lmotmp[0]!=-1 && _lmotmp[1]==-1 && _lmotmp[0]!=nr && _lmotmp[1]!=c) {
		document.getElementById("down"+_lmotmp[0]).style.background="#33CC99";
		single_pull_down(nr,c);
	} else {
		single_pull_down(nr,c);
	}
}

function single_pull_down(nr,c) {
	if (timerID == "" && (self_menu.length-1)>nr){
		to = self_menu[nr+1][1];
		begin = nr + 2;
		if (timerID != "") clearTimeout(timerID);
		if (self_menu[nr+1][2] == 0) {
//alert ("opening menue: " + nr + "; c="+c);
			// check if 'single' menue was opened before
			self_menu[nr+1][2] = 1;
			if(nr == (self_menu.length-2)) {to++;}
			epull_down(begin,to,0);
			document.getElementById("scrollimg"+nr).src = picsDir+"/arrowUp.gif";
			document.getElementById("down"+nr).style.background="#7ADEBD";
			setLastMenuOpened(nr,c);
		} else {
//alert ("closing menue: " + nr + "; c="+c);
			to = 0;
			self_menu[nr+1][2] = 0;
			name = "down"+(nr+2);
			open_item = 0;
			for(i=0;i<nr;i++){
				if(self_menu[i][2] == 1) {open_item += self_menu[i][1];}
			}
			if (N == false) {open_item-= (c*1)};
			if (nr== (self_menu.length-2)) {val = self_menu[self_menu.length-1][1];to=-1;}
			else  val = parseInt(document.getElementById(name).style.top) -(open_item)-(c*height);
			epull_up(begin,to,val);
			document.getElementById("scrollimg"+nr).src = picsDir+"/arrowDown.gif";
			document.getElementById("down"+nr).style.background="#33CC99";
			setLastMenuOpened(-1,-1);
		}
	}
}

function epull_down(nr,to,nowv) {
	name = "down" + (nr-1);
	obj = document.getElementById(name).style.clip = "rect(0,"+menuewidth+","+(nowv+1)+",0)";
	for (i=nr;i<self_menu.length;i++){
		name = "down" + i;
		obj = document.getElementById(name);
		obj.style.top = parseInt(obj.style.top)+1;
	}
	nowv++;
	if(nowv < to) { 
		timerID = setTimeout("epull_down("+nr+","+to+","+nowv+")", speed);
	} else {
		timerID = "";	
	}
}

function epull_up(nr,to,nowv){
	name = "down" + (nr-1);
	obj = document.getElementById(name).style.clip = "rect(0,"+menuewidth+","+nowv+",0)";
	for (i=nr;i<self_menu.length;i++){
		name = "down" + i;
		obj = document.getElementById(name);
		obj.style.top = parseInt(obj.style.top)-1;
	}
	nowv--;
	if(nowv > to){ 
		timerID = setTimeout("epull_up("+nr+","+to+","+nowv+")", speed);
	} else {
		timerID = "";
		//alert ("hallo; " + toPullDownC + ", " + toPullDownNr);
		if (toPullDownC != "" &&  toPullDownC != -1 && toPullDownNr!= -1) { 
			single_pull_down(toPullDownNr, toPullDownC);
			toPullDownC = "";
			toPullDownNr = "";
		}
	}
}

function startup(nr){
	write_menu();
		if (nr != 0){
			for(i=0;i<self_menu.length;i++){
				if(self_menu[i][3] == nr) {
				setLastMenuOpened(i,nr);
				single_pull_down(i,nr);
				}
			}
		}
}  

function setLastMenuOpened (nr, i) {
	document.getElementsByName("_lastMenuOpened")[0].value = nr + ","+i;	
}

function getLastMenuOpened () {
	var _lmtmp = document.getElementsByName("_lastMenuOpened")[0].value;	
	var _lmtmpArr =_lmtmp.split(",");
	_lmtmpArr[0]=parseInt(_lmtmpArr[0]);
	_lmtmpArr[1]=parseInt(_lmtmpArr[1]);
	return _lmtmpArr;
}

