//Diverse Elemente bei kleiner Fenstergröße verändern
function check_resolution() {

	//Foto auf der Startseite
	obj_startbild = document.getElementById('bildcontainer')

	if(obj_startbild){
		if (document.body.offsetWidth <= 1000 && document.body.offsetWidth > 800){
			obj_startbild.style.background = 'url(images/startbild1024x768.jpg) no-repeat center bottom';		
		} else if (document.body.offsetWidth <= 800){
			obj_startbild.style.background = 'url(images/startbild800x600.jpg) no-repeat center bottom';
		} else {
			obj_startbild.style.background = 'url(images/startbild.jpg) no-repeat center bottom';
		}
	}

	var array = new Array('author','functions','adresse1','adresse2','adresse3');
	var obj;

	if (document.body.offsetWidth < 800) {
		for(i = 0; i < array.length; i++) {
			obj = document.getElementById(array[i])
			if(obj)
				obj.style.display = 'none'
		}
	} else {
		for(i = 0; i < array.length; i++) {
			obj = document.getElementById(array[i])
			if(obj)
				obj.style.display = ''
		}
	}

}

function changePic(obj2, over) {
	var obj = obj2.getElementsByTagName('IMG')[0];
	var tmp_sub = 'FOLDER_' + akt_sub;
	if (obj && (obj2.id != tmp_sub)) {
		file = obj.src;
		tmp_img= new Image();
		if (over) {
			tmp_img.src = file.replace(/2*\.gif/, '2.gif');
		} else {
			tmp_img.src = file.replace(/2+\.gif/, '.gif');
		}
		obj.src = tmp_img.src;
	}
}

function changeDisplay(div_id, if_, then_) {
	var elem = document.getElementById(div_id);
	if (elem && elem.style.display == if_)
		elem.style.display = then_;
}

function changeVisibility(div_id, if_, then_) {
	var elem = document.getElementById(div_id);
	if (elem && elem.style.visibility == if_)
		elem.style.visibility = then_;
}

function open_sub(SM_SHORT) {
	if (akt_sub != SM_SHORT) {
		 changeDisplay(akt_sub, 'block', 'none');
		 changeDisplay(SM_SHORT, 'none', 'block');
		 akt_sub=SM_SHORT;
	}
}

function changevis(layID) {
	var myLayer = document.getElementById(layID);
	
	if (myLayer.style.display=="none") {
		myLayer.style.display="";
		} else {
		myLayer.style.display="none";
	}
}

function getAdr(prefix, postfix, lnkparam, lnktxt) {
	lnktxt = lnktxt.replace(/TMPL_MAIL/, prefix + '@' + postfix);
	document.write('<a ' + lnkparam + ' href="mailto:' + prefix + '@' + postfix + '">' + lnktxt);
}

/*printjob*/
function printjob() {
	if (document.all && (navigator.appVersion.indexOf("Mac") != -1)) {
		self.focus();
		alert("Drucken-Funktion unter Macintosh nicht moeglich! \nBitte verwenden Sie Datei/Drucken");
	} else {
		if (document.all && navigator.appVersion.substring(22,23)==4) {
			self.focus();
			var OLECMDID_PRINT = 6;
			var OLECMDEXECOPT_DONTPROMPTUSER = 2;
			var OLECMDEXECOPT_PROMPTUSER = 1;
			var WebBrowser = '<object id="WebBrowser1" width="0" height="0" classid="CLSID:8856F961-340A-11D0-A96B-00C04FD705A2"></object>';
			document.body.insertAdjacentHTML('beforeEnd',WebBrowser);
			WebBrowser1.ExecWB(OLECMDID_PRINT,OLECMDEXECOPT_DONTPROMPTUSER);
			WebBrowser1.outerHTML = '';
		} else{
			self.focus();
			window.print();
		}
	}
}


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');
	if(popupmenuoldonload)
		popupmenuoldonload();
}

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";
		}
	}
}

