function browserOs() {
	userAgent = navigator.userAgent.toLowerCase();
	if (userAgent.indexOf("linux") != -1) return "Linux"
	else if (userAgent.indexOf("x11") != -1) return "Unix"
	else if (userAgent.indexOf("mac") != -1) return "Mac"
	else if (userAgent.indexOf("win") != -1) return "Windows"
	else return "Unknown";
}

function browserCheck(str) {
	userAgent = navigator.userAgent.toLowerCase();
	idx = userAgent.indexOf(str);
	if (idx != -1) {
		globVersion = parseFloat(userAgent.charAt(str.length + idx + 1));
		return true;
	}
	return false;
}

function browserObject(str) {
	this.os = browserOs();
	this.platform = navigator.platform;
	this.appName = navigator.appName;
	this.appCodeName = navigator.appCodeName;
	this.appVersion = navigator.appVersion;
	this.userAgent = navigator.userAgent;

	if (browserCheck("opera")) {
		this.version = globVersion;
		this.name = "Opera";
		this.alias = this.name;
	}
	else if (browserCheck("msie")) {
		this.version = globVersion;
		this.name = "Internet Explorer";
		this.alias = "IE";
	}
	else if (navigator.appName == "Netscape") {
		this.version = parseFloat(navigator.appVersion);
		this.name = "Netscape Navigator";
		this.alias = "NS";
	}
	else {
		this.version = 0;
		this.name = "Unknown";
		this.alias = "Unknown";
	}
}

function showHideLayers() {
	var i,p,v,obj,args = showHideLayers.arguments;
	for (i=0; i<(args.length-2); i+=3) if ((obj=findObj(args[i]))!=null) { v=args[i+2];
		if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
		obj.visibility=v;}
}

function findObj(n, d) {
	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=findObj(n,d.layers[i].document);
	if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function changePage() {
	frm = document.frmBoendeMbs;
	window.location.href = frm.map.value;
}

function showHelp(objEl, srcEl) {
	if (b.alias == "IE" && b.version >= 4) {
		obj = findObj(objEl);
		if (obj != null) {
			obj.style.top = globy;
			obj.style.left = globx - 190;
			obj.style.visibility = "visible";
			globj = obj;
			if (event != null) event.cancelBubble = true;
		}
	}
	else if (b.alias == "NS" && b.version >= 5) {
		obj = findObj(objEl);
		if (obj != null) {
			obj.style.top = globy;
			obj.style.left = globx - 190;
			obj.style.visibility = "visible";
			globj = obj;
			document.onclick = nsFix;
		}
	}
	else if (b.alias == "NS" && b.version >= 4) {
		obj = findObj(objEl);
		if (obj != null) {
			obj.top = globy;
			obj.left = globx - 190;
			obj.visibility = "visible";
			globj = obj;
		}
	}
}

function showHelp2(objEl, srcEl) {
	if (b.alias == "IE" && b.version >= 4) {
		obj = findObj(objEl);
		if (obj != null) {
			obj.style.top = globy;
			obj.style.left = globx - 25;
			obj.style.visibility = "visible";
			globj = obj;
			if (event != null) event.cancelBubble = true;
		}
	}
	else if (b.alias == "NS" && b.version >= 5) {
		obj = findObj(objEl);
		if (obj != null) {
			obj.style.top = globy;
			obj.style.left = globx - 25;
			obj.style.visibility = "visible";
			globj = obj;
			document.onclick = nsFix;
		}
	}
	else if (b.alias == "NS" && b.version >= 4) {
		obj = findObj(objEl);
		if (obj != null) {
			obj.top = globy;
			obj.left = globx - 25;
			obj.visibility = "visible";
			globj = obj;
		}
	}
}

function nsFix() {
	document.onclick = handleClick;
}

function handleMouseMove(e) {
	if (b.alias == "NS") {
		globx = e.pageX;
		globy = e.pageY;
	}
	else {
		globx = event.clientX;
		globy = event.clientY;
	}
}

function hideHelp() {
	if ((b.alias == "NS") && (b.version < 5)) {
		if (globj != null) {
			globj.visibility = "hidden";
			globj = null;
		}
	}
	else {
		if (globj != null) {
			globj.style.visibility = "hidden";
			globj = null;
		}
	}
}

function handleClick(e) {
	hideHelp();
}

var globj = null;
var globx = null;
var globy = null;
var b = new browserObject();

function init() {
	if (b.alias == "NS" && b.version >= 5) {
		window.onmousemove = handleMouseMove;
		document.onclick = handleClick;
	}
	else if (b.alias == "NS" && b.version < 5) {
		window.captureEvents(Event.MOUSEMOVE);
		window.onMouseMove = handleMouseMove;

		window.captureEvents(Event.MOUSEDOWN);
		window.onMouseDown = handleClick;
	}
	else {
		document.onmousemove = handleMouseMove;
		document.onclick = handleClick;
	}
}

window.onload = init;
