function popup(url,typ,para1,width,height)
{
	attrib = "";
	Y = (screen.height - width) / 2;
	X = (screen.width - height) / 2;
	X = Math.round(X);
	Y = Math.round(Y);
	if (para1 == 'CENTER') {attrib += 'height=' + height + ',width=' + width + ',top=' + Y + ',left=' + X;}
	if (typ == 'TYP1') {attrib += ",scrollbars=no";}
	if (typ == 'TYP2') {attrib += ",scrollbars=yes";}
	if (typ == 'TYP3') {attrib += ",scrollbars=yes,menubar=yes";}
	x = Math.random();
	fenster = window.open(url, 'win', attrib);
	return false;
}


var popupmenuoldonload = window.onload;
window.onload = function() {
	var nav = document.getElementById('treeNavigation');
	if(nav)
	{
		var uls = nav.getElementsByTagName('ul');
	
		for(var i = 0; i < uls.length; i++)
			new xMenu1(uls[i], 0, 'mouseover');
	}
	
	if(popupmenuoldonload)
		popupmenuoldonload();
}

var newWnd;

function open_dia(pic, width, height) {
	if (newWnd)
		newWnd.close();
	newWnd = window.open('','tmp','height='+height+',width='+width+',scrollbars=no');
	var img_str='<html><head><title>Bild</title><style type="text/css">body{margin:0px;padding:0px;}</style></head><body margin=0 padding=0><img src="'+pic+'" alt=""></body></html>';

	if (newWnd.document)
		newWnd.document.write(img_str);
	newWnd.focus();
	return false;
}

function xMenu1(menu, mouseMargin, openEvent) {
	var isOpen = false;
	if (menu)
		xAddEventListener(menu.parentNode, openEvent, onOpen, false);

	function onOpen() {
		if (!isOpen) {
			xShow(menu);
			HideSelects(xPageX(menu), xPageY(menu), xWidth(menu), xHeight(menu));
			xAddEventListener(document, 'mousemove', onMousemove, false);
			isOpen = true;
		}
	}
	function onMousemove(ev) {
		var e = new xEvent(ev);
		contains = (xHasPoint(menu, e.pageX, e.pageY, -mouseMargin) || xHasPoint(menu.parentNode, e.pageX, e.pageY, -mouseMargin));
		if(!contains) {
			var submenus = menu.getElementsByTagName('UL');
			for(var i = 0; i < submenus.length; i++) {
				if(xHasPoint(submenus[i], e.pageX, e.pageY, -mouseMargin)) {
					contains = true;
					break;
				}
			}
		}
		if(!contains) {
			xHide(menu);
			HideSelects(0,0,0,0);
			xRemoveEventListener(document, 'mousemove', onMousemove, false);
			isOpen = false;
		}
	}
}

var sel;
function HideSelects(x,y,w,h) {
	if(xIE4Up && !xMac) {
		var selx,sely,selw,selh,i
		if(!sel) sel = document.getElementsByTagName("SELECT");
		for(i=0;i<sel.length;i++){
			selx=xPageX(sel[i]);
			sely=xPageY(sel[i]);
			selw=sel[i].offsetWidth;
			selh=sel[i].offsetHeight;
			sel[i].style.visibility = (selx+selw>x && selx<x+w && sely+selh>y && sely<y+h) ? "hidden" : "visible";
		}
	}
}
