
// +-----------------------------------------+
// | This script is called from the homepage |
// | to handle warning message to users that |
// | the website will be restarting in XX    |
// | minutes.                                |
// +-----------------------------------------+
// | IMacNeill 02.17.06 v1.0                 |
// +-----------------------------------------+
var sRestartIn = "";
var bInit = true;

function CheckAlert()
{
	dateFuture = new Date(2006,1,17,17,00,00);
	dateNow = new Date();
	amount = dateFuture.getTime() - dateNow.getTime();		

	if (amount > 0)
	{
		days=0;
		hours=0;
		mins=0;
		secs=0;

		amount = Math.floor(amount/1000);

		days=Math.floor(amount/86400);
		amount=amount % 86400;

		hours=Math.floor(amount/3600);
		amount=amount % 3600;

		mins=Math.floor(amount/60);
		amount=amount % 60;

		secs=Math.floor(amount);
		
		window.status = "This website will restart in => " + ((mins < 10) ? "0" : "") + mins + ":" + ((secs < 10) ? "0" : "") + secs + " PLEASE COMPLETE OR SAVE YOUR WORK NOW!";
		if (mins > 0)
			sRestartIn = (mins + 1) + " minute" + (((mins + 1) != 1) ? "s" : "");
		else
			sRestartIn = secs + " second" + ((secs != 1) ? "s" : "");
	}
	else
	{
		// Means we were displaying an alert
		if (bInit == false)
		{
			sRestartIn = "";
			oWrnDiv = document.getElementById("WEBRSTMSG");

			for (i = (oWrnDiv.childNodes.length - 1); i >= 0; i--)
				oWrnDiv.childNodes[i].removeNode(true);

			oAltFnt = document.createElement("font");
			oAltFnt.className = "WEBRSTALT";
			oAltTxt = document.createTextNode("PLEASE NOTE! ");
			oAltFnt.appendChild(oAltTxt);

			oWrnMsg = document.createTextNode("We are currently in the process of enhancing this website, as such your session has been expired. Please wait approximately 1 minute from the time you read this message to reload this webpage.");

			oWrnDiv.appendChild(oAltFnt);
			oWrnDiv.appendChild(oWrnMsg);

			window.status = "We are currently in the process of enhancing this website, as such your session has been expired. Please wait approximately 1 minute from the time you read this message to reload this webpage.";
		}	
	}
			

	if (sRestartIn != "")
	{
		if (bInit)
		{
			oWrnDiv = document.getElementById("WEBRSTMSG");
			
			oAltFnt = document.createElement("font");
			oAltFnt.className = "WEBRSTALT";
			oAltTxt = document.createTextNode("ALERT! ");
			oAltFnt.appendChild(oAltTxt);

			oWrnSg1 = document.createTextNode("We will be enhancing this website in ");
			oWrnMsg = document.createElement("font");
			oWrnMsg.id = "AlertBlock";
			oWrnSg2 = document.createTextNode(sRestartIn);
			oWrnMsg.appendChild(oWrnSg2);
			oWrnSg3 = document.createTextNode(", at which point your session will be lost. Please complete or save any work before this time. Website will be down for less than a minute to perform the update, after which you can start a new session.");

			oWrnDiv.appendChild(oAltFnt);	
			oWrnDiv.appendChild(oWrnSg1);
			oWrnDiv.appendChild(oWrnMsg);
			oWrnDiv.appendChild(oWrnSg3);

			oWrnDiv.style.display = "block";

			bInit = false;
		}
		else
		{
			oAltTme = document.getElementById("AlertBlock").childNodes[0];
			oNewTme = document.createTextNode(sRestartIn);
			oAltTme.replaceNode(oNewTme);
		}

		setTimeout("CheckAlert()", 1000);
	}
}

CheckAlert();