// JavaScript Document, created by Rahul Banerjee '10 for Brown SASA.

var errorMsg_div = null; //will become the error message div
var errorMsg_countDown = null; //will become the error message interval

addOnload(setupErrorDiv);
function setupErrorDiv() {
	if(!document.getElementById('errorMsg_div')) return;
	errorMsg_div = document.getElementById('errorMsg_div');
	errorMsg_countDown = setInterval(returnLoweredSeconds,1000);
}
function returnLoweredSeconds() {
	var numberOfSeconds = Number(errorMsg_div.lastChild.innerHTML.replace(/\D/g,'')) - 1;
	if(numberOfSeconds < 1) window.location.href = WEB_ROOT + 'home.php';
	var newText = String(numberOfSeconds);
	newText += (numberOfSeconds != 1) ? ' seconds.' : ' second.';
	var regEx = /^(.+\b)\d.+$/;
	errorMsg_div.lastChild.innerHTML = errorMsg_div.lastChild.innerHTML.replace(regEx,'$1' + newText);
}