var intervalVar = setInterval(countDownShutdown, 60000);

function countDownShutdown() {
	var elementVisible = document.getElementById("contentForm:shutdownIfVisible");
	
	if (null != elementVisible) {
		var visible = elementVisible.innerHTML;
		
		if (visible == 'true') {
			var element = document.getElementById("contentForm:shutdownInMinuten");
			var elementText = document.getElementById("contentForm:shutdownInMinutenText");
			var elementRedAt = document.getElementById("contentForm:shutdownRedAt");
			var shutdownPopupMinute = document.getElementById("contentForm:shutdownPopupMinute");
			var popupShutdown = document.getElementById("headerForm:popupShutdown");
			var divLoader = document.getElementById("divLoader");

			var shutdownMinute = shutdownPopupMinute.innerHTML;
			var shutdown = element.innerHTML;
			var redAt = elementRedAt.innerHTML;
			
			shutdown --;
			
			if (shutdown == -2) {
				element.innerHTML = "...";
				element.style = "";
				elementText.style = "";
				clearInterval(intervalVar);
			} else if (shutdown > redAt) {
				element.innerHTML = shutdown;
				element.style = "";
				elementText.style = "";
				if (shutdown <= shutdownMinute && null != popupShutdown) {
					popupShutdown.style.visibility='visible';
					divLoader.style.visibility='visible';
				}
			} else if (shutdown > 1) {
				element.innerHTML = shutdown;
				element.style = "color: #FF0000;";
				elementText.style = "color: #FF0000;";
				if (shutdown <= shutdownMinute && null != popupShutdown) {
					popupShutdown.style.visibility='visible';
					divLoader.style.visibility='visible';
				}
			} else if (shutdown > 0) {
				element.innerHTML = "unter einer Minute!";
				element.style = "color: #FF0000;";
				elementText.style = "display: none;";
			} else if (shutdown != "...") {
				element.innerHTML = "System wird heruntergefahren ...!";
				element.style = "color: #FF0000;";
				elementText.style = "display: none;";
			}
		}
	}
	
	return;
}