var nn=document.layers;

var ex,ey;
var mx,my;

function hideError(){
	return true;
}
window.onerror = hideError;

if (document.layers) {
	window.captureEvents(Event.MOUSEMOVE);
	window.onmousemove = setXY;
}

if (!(navigator.userAgent.indexOf('Opera') > -1) && document.getElementById) document.addEventListener("mousemove", setXY, false);
if (navigator.userAgent.indexOf('Opera') > -1) document.onmousemove = setXY;

function setXY(e) {
	if(navigator.userAgent.indexOf('Opera') > -1) {
		ex = e.clientX;
		ey = e.clientY;
	}
	else {
		ex=e.pageX;
		ey=e.pageY;
	}
}

function MM_reloadPage(init) { //reloads the window if Nav4 resized
	if (init==true) with (navigator) {
		if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
			document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }
	}
	else
		if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}

MM_reloadPage(true);

function show(button,layer) {
	(nn)?img=document.images[button]:img=document.getElementById(button);
	move(layer,findPosX(img),findPosY(img)+15);
	hideall();
	(nn)?imgc=document.layers[layer].document.images.length:imgc=document.getElementById(layer).getElementsByTagName('img').length;
	if (imgc>2) {
		(nn)?document.layers[layer].visibility='show':document.getElementById(layer).style.visibility='visible';
	}
}

function hide(layer) {
	var obj=null; (nn)?obj=document.layers[layer]:obj=document.getElementById(layer);
	(nn && hide)?obj.visibility='hide':obj.style.visibility='hidden';
}

function hideall(layer) {
	if (nn) for(i=0;i<document.layers.length;i++) document.layers[i].visibility='hide'
	else {
		var layers=document.getElementsByTagName('div');
		for(i=0;i<layers.length;i++) if (layers[i].style.visibility) layers[i].style.visibility='hidden';
	}
}

function move(layer,x,y) {
	if (nn) var obj=document.layers[layer];
	else var obj=document.getElementById(layer).style;
	obj.top=y; obj.left=x;
}

function findPosX(obj) {
	var curleft = 0;
	if (document.getElementById || document.all) {
		while (obj.offsetParent) {
			curleft += obj.offsetLeft
			obj = obj.offsetParent;
		}
	}
	else
		if (document.layers) curleft += obj.x;
	return curleft;
}

function findPosY(obj) {
	var curtop = 0;
	if (document.getElementById || document.all) {
		while (obj.offsetParent) {
			curtop += obj.offsetTop
			obj = obj.offsetParent;
		}
	}
	else
		if (document.layers)	curtop += obj.y;
	return curtop;
}

function check2hide(button,layer) {
	var obj=null; (nn)?obj=document.layers[layer]:obj=document.getElementById(layer);
	if (document.all) {
		ex = event.clientX+document.body.scrollLeft; ey = event.clientY+document.body.scrollTop; x = parseInt(obj.style.left)+5; y = parseInt(obj.style.top); w = parseInt(obj.style.width)-5; h = obj.clientHeight;
	}
	else
		if (document.layers) {
			x = obj.left; y = obj.top; w = obj.document.width; h = obj.document.height;
		}
		else
			if (!(navigator.userAgent.indexOf('Opera') > -1) && document.getElementById) {
				x = parseInt(obj.style.left)+5; y = parseInt(obj.style.top); w = parseInt(obj.style.width)-10; h = obj.offsetHeight-5;
			}
			else
				if (navigator.userAgent.indexOf('Opera') > -1) {
					x = parseInt(obj.style.left); y = parseInt(obj.style.top); w = parseInt(obj.style.pixelWidth); h = obj.style.pixelHeight;
				}
	if (!(ex>x && ex<(x+w) && ey>(y-2) && ey<(y+h))) hide(layer);
	else show(button,layer);
}

function MM_swapImgRestore() { //v3.0
	var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.0
	var p,i,x;
	if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
		d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);
	}
	if(!(x=d[n])&&d.all) x=d.all[n];
	for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
	for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
	if(!x && document.getElementById) x=document.getElementById(n);
	return x;
}

function MM_swapImage() { //v3.0
	var i,j=0,x,a=MM_swapImage.arguments;
	document.MM_sr=new Array;
	for(i=0;i<(a.length-2);i+=3)
		if ((x=MM_findObj(a[i]))!=null) {
			document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];
		}
}

function MM_preloadImages() { //v3.0
	var d=document;
	if(d.images) {
		if(!d.MM_p) d.MM_p=new Array();
		var i,j=d.MM_p.length,a=MM_preloadImages.arguments;
		for(i=0; i<a.length; i++)
			if (a[i].indexOf("#")!=0) {
				d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];
			}
	}
}

function openWin(sourceFile,winWidth,winHeight,scroll)
{
	if (winWidth>800) {
		winWidth=800;
		scroll="yes";
	}
	if (winHeight>600) {
		winHeight=600;
		scroll="yes";
	}
	var win=window.open(sourceFile,"PopUp","height="+(winHeight)+",width="+(winWidth)+",innerWidth="+winWidth+",innerHeight="+winHeight+",toolbar=no,location=no,status=no,menubar=no,scrollbars="+scroll+",resizable=no");
	win.document.open();
	win.document.write('<html><head><style type="text/css">body {padding:0px; margin-left:0px; margin-right:0px; margin-top:0px; margin-bottom:0px}</style></head><body leftmargin="0" topmargin="0" rightmargin="0" bottommargin="0" margin-left="0" margin-right="0" margin-top="0" margin-bottom="0"marginleft="0" marginright="0" margintop="0" marginbottom="0" marginwidth="0" marginheight="0">');
	win.document.write('<img src="'+sourceFile+'"');
	win.document.write('</body></html>');
	win.document.close();
}

function ChangePicture(image_object, new_source) {
	image_object.src = new_source;
}

function BgCol(id,farbe) {
	if (document.all)
		document.all[id].style.backgroundColor=farbe;
	else
		if (document.getElementById)
			document.getElementById(id).style.backgroundColor=farbe;
		else
			if (document.layers) 
				document.layers[id].bgColor=farbe;
}

function ImageAndBgColorChange(image_object, new_source, row_object, new_color) {
	ChangePicture(image_object, new_source);
	BgCol(row_object, new_color)
}

function popupWindow(SeitenURL, window_width, window_height, scroll_bar) {
	var top_margin = (screen.height - window_height) / 2;
	var left_margin = (screen.width - window_width) / 2;
	newWindow = window.open(SeitenURL, "newWindow", "width=" + window_width 
		+ ",height=" + window_height
		+ ",scrollbars=" + scroll_bar
		+ ",left=" + left_margin
		+ ",top=" + top_margin);
	newWindow.moveTo(left_margin,top_margin);
	newWindow.resizeTo(window_width, window_height);
	newWindow.focus();
}

function ChangeHref(URLAdr) {
	document.location.href = URLAdr;
	newWindow.document.open();
	newWindow.document.close();
}

function popupPicWindow(image_name, image_width, image_height, image_alt) {
	var top_margin = (screen.height - image_height) / 2;
	var left_margin = (screen.width - image_width) / 2;
	newWindow = window.open("", "newWindow", "width=" + image_width 
		+ ",height=" + image_height
		+ ",scrollbars=no,left=" + left_margin
		+ ",top=" + top_margin);
	newWindow.moveTo(left_margin,top_margin);
	newWindow.resizeTo(image_width, image_height);
	newWindow.document.open();
	newWindow.document.write('<html><title>' + image_alt
		+ '</title><body bgcolor=\"#FFFFFF\" leftmargin=\"0\" topmargin=\"0\" marginheight=\"0\" marginwidth=\"0\">');
	newWindow.document.write('<img src=\"' + image_name + '\" width=\"' + image_width
		+ '\" height=\"' + image_height + '\" alt=\"' + image_alt + '\">');
	newWindow.document.write('</body></html>');
	newWindow.document.close();
	newWindow.focus();
}


