var MENUname = new Array();
var MENUtiefe = new Array();
var MENUc = 0;
var AutoCloseCount = -1;

function dohide(L) {
	if (document.layers) {
		obj = eval("document."+L);
		obj.visibility = "hidden";
	} 
	if (document.all) {
		obj = eval(L+".style");
		obj.visibility = "hidden";
	}
	if (!document.all && document.getElementById) {
		document.getElementById(L).style.visibility="hidden";
	}

}

function doshow(L) {
	if (document.layers) {
		obj = eval("document."+L);
		obj.visibility = "visible";
	} 
	if (document.all) {
		obj = eval(L+".style");
		obj.visibility = "visible";
	}
	if (!document.all && document.getElementById) {
		document.getElementById(L).style.visibility="visible";
	}
}

function showMenu(ID,Tiefe) {
	for (i=0;i<MENUc;i++) {
		if (MENUtiefe[i]>Tiefe) {
			dohide(MENUname[i]);
		}
	}
	for (i=0;i<MENUc;i++) {
		if (MENUname[i]==("XMenu"+ID)) {
			doshow(MENUname[i]);
			break;
		}
	}
}

function autoclose() {
	if (AutoCloseCount>0) {
		AutoCloseCount--;
	} else if (AutoCloseCount==0) {
		AutoCloseCount=-1;
		for (i=0;i<MENUc;i++) {
			if (MENUtiefe[i]>1) {
				dohide(MENUname[i]);
			}
		}
	}
	setTimeout("autoclose()",400);
}

setTimeout("autoclose()",400);

function closeMenu(ID,Tiefe) {
	for (i=0;i<MENUc;i++) {
		if (MENUtiefe[i]>Tiefe) {
			dohide(MENUname[i]);
		}
	}
}

/**
* Öffnen eines Popup-Fensters
*
* @param	mixed	URL oder Link-Tag mit href-Attribut
* @param	integer	Popup-Breite
* @param	integer	Popup-Höhe
* @param	string	Fenstername (optional)
*/
function popup(url, width, height, name)
{
	if (typeof url.getAttribute != 'undefined')
	{
		url = url.getAttribute('href');
	}

	if (typeof name == 'undefined')
	{
		name = '_blank';
	}

	width = Math.min(screen.availWidth, width);
	height = Math.min(screen.availHeight, height);

	var pos_x = Math.round((screen.availWidth - width) / 2);
	var pos_y = Math.round((screen.availHeight - height) / 4);

	return window.open(url, name, 'width=' + width + ', height=' + height + ', left=' + pos_x + ', top=' + pos_y + ', resizable=1, scrollbars=1, status=1');
}