if(document.getElementById("timeuntilinactivity")) {
	var minutes = 10;
	var seconds = 0;
	var asked = false;
	var updateTimeToTimeout = window.setInterval(function() {
		document.getElementById("timeuntilinactivity").innerHTML = minutes + ":" + seconds;
		if(seconds!=0) seconds--;
		if(seconds==0) {
			minutes--;
			seconds = 59;
		}
		if(minutes < 0 && !asked) {
			var ok = window.confirm("Ihre Sitzung ist abgelaufen. Zurück zum Login?");
			if(ok) window.location.href = "login.php?reason=session_timed_out&forward_to=" + window.location.href;
				asked = true;
		}
	},1000);
}
document.getElementById("shown_site").addEventListener("change",function() {
	document.getElementById("site_change_state").innerHTML = "Ändern...";
	var xhr = new XMLHttpRequest();
	xhr.open("GET","csite.php?s=" + this.options[this.selectedIndex].getAttribute("name"));
	xhr.addEventListener("load",function() {
		document.getElementById("site_change_state").innerHTML = "Geändert. Laden...";
		window.location.reload(true);
	});
	xhr.send();
});
var confirmed;
window.addEventListener("blur",function() {
	if(!confirmed) {
		window.confirm("Vorsicht. Loggen Sie sich aus, wenn Sie die Seite verlassen wollen.");
		confirmed = true;
	}
});