function createXMLObject() {
	try {
		if (window.XMLHttpRequest) {
			xmlhttp = new XMLHttpRequest();
		}
		// code for IE
		else if (window.ActiveXObject) {
			xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
		}
	}
	catch (e) {
		xmlhttp = false;
	}
	return xmlhttp;
}

function logoutHack() {
	var agt = navigator.userAgent.toLowerCase();
	if (agt.indexOf("msie") != -1) {
		// IE clear HTTP Authentication
		document.execCommand("ClearAuthenticationCache");
	}
	else {
		var xmlhttp = createXMLObject();
		xmlhttp.open("GET", location.protocol + "//" + location.host + "/intra/", true, "logout");
		xmlhttp.send("");
		//xmlhttp.abort();
	}
	
	return false;
}


var showLogoutLink = true; // false, wenn der Logout-Link nicht angezeigt werden soll


if (showLogoutLink) {
	window.onload = function () {
		var links = document.getElementsByTagName("a");
		var loginLink, logoutLink, br, p;
		for (var i=0; i<links.length; i++) {
			loginLink = links[i];
			if (loginLink.innerHTML.toLowerCase() == "login") {
			
				p = loginLink.parentNode;
				br = document.createElement("br");
				
				logoutLink = document.createElement("a");
				logoutLink.innerHTML = "Logout";
				logoutLink.href = location.href;
				logoutLink.title = "Falls eine Passwortabfrage erscheint, bitte \"Abbrechen/Cancel\" klicken";
				logoutLink.setAttribute("onclick", "return logoutHack();");
				
				p.insertBefore(br, loginLink.nextSibling);
				p.insertBefore(logoutLink, br.nextSibling);
				
				break;
			}
		}
	};
}
