function checkTimeout()
{
	TrueStars.Controls.KeepAlive.IsShuttingDown(checkTimeOutCallback);
}


function checkTimeOutCallback(res)
{
	var data = res.value;
	if(data[0]==1)
	{
		var down = "";
		if(data[1]=="true")
		{
			if(location.href.toLowerCase().indexOf("login.aspx")>-1)
			{
			
				
			down = "TrueStars CMS<sup>+</sup> is gestopt voor onderhoud.<br>U kunt weer inloggen zodra deze melding niet meer zichtbaar is.";
			} else {
				TrueStars.Controls.KeepAlive.ShutDown();
				location.href = location.protocol+"//"+location.hostname+"/TrueStars/Login.aspx";

			}	
		} 
		else
		{
			var now = new Date();
			var dt = data[2];
			var time = ((dt.getHours()*60 + dt.getMinutes())- (now.getHours()*60 + now.getMinutes()));
			
			down = "TrueStars CMS<sup>+</sup> wordt gestopt voor onderhoud in " + time + ((time>1)?" minuten":" minuut")+".<BR>Sla uw wijzigingen op en sluit TrueStars CMS<sup>+</sup> af om het verlies van gegevens te voorkomen.<br>U wordt automatisch naar de aanmeldpagina gestuurd als de tijd verstreken is.";
			if(time<0) 
				{
TrueStars.Controls.KeepAlive.ShutDown();
				location.href = location.protocol+"//"+location.hostname+"/TrueStars/Login.aspx";
}
		}

		var div = document.getElementById("divShuttingDown");
		div.innerHTML = down + ((data[3]!="")?"<Br>Reden: "+data[3]:"");
		div.style.display = "block";
			
		try
		{
		document.getElementById(UNIQUE_ID+"txtUserName").disabled = true;
		document.getElementById(UNIQUE_ID+"txtPassword").disabled = true;
		document.getElementById(UNIQUE_ID+"tbDomain").disabled = true;
		document.getElementById(UNIQUE_ID+"lbLogin").disabled = true;
		} catch (err) { }

	}
	else if(data[0]==2)
	{
		var div = document.getElementById("divShuttingDown");
		div.innerHTML = data[2];
		div.style.display = "block";

	}
	else
	{
		document.getElementById("divShuttingDown").style.display = "none";
		
		try
		{
		document.getElementById(UNIQUE_ID+"txtUserName").disabled = false;
		document.getElementById(UNIQUE_ID+"txtPassword").disabled = false;
		document.getElementById(UNIQUE_ID+"tbDomain").disabled = false;
		document.getElementById(UNIQUE_ID+"lbLogin").disabled = false;
		} catch (err) { }
		
	}
	
	setTimeout(checkTimeout,60000);
}

