function getWindowWidth() {
                if (window.innerWidth)
                        return window.innerWidth;
                else if (document.body && document.body.offsetWidth)
                        return document.body.offsetWidth;
        }

function check_resolution() {
	var container = document.getElementById('container');
	var nav = document.getElementById('navcontainer');
	var content = document.getElementById('content');
	var contactinfo = document.getElementById('contactinfo');
        var w=getWindowWidth();
	if (w < 995) {
		container.style.display = 'none'
		nav.style.right = content.style.right = contactinfo.style.right = '5px';
	} else {
		container.style.display = '';
		nav.style.right = '';
		content.style.right = '';
		contactinfo.style.right = '';
	}
}
window.onresize = check_resolution;

var popupmenuoldonload = window.onload;
window.onload = function() {
	var nav = document.getElementById('nav');
	var uls = nav.getElementsByTagName('UL');
	for(var i = 0; i < uls.length; i++)
		new xMenu1(uls[i], 0, 'mouseover');
	check_resolution();
	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";
		}
	}
}

