setTimeout("TimerStart()",1000); //check for update warnings

//Vars and functions to display time to system Update
var TimeLeft = null;
var TimeOn = null;

//called by onload of page
function TimerStart(){

	//check for tTimer, if it exists, page has finished loading, 
	//otherwise we need to call this function again in a couple seconds.
	var x = GetElement("UpdateNotification1_tTimer")
	if (x==null){
		setTimeout("TimerStart()",1100); //call again in about 1 second
		return;
	}
	
	TimeLeft = x.value; //total time left in seconds

	if (TimeLeft == ''){return;} //no timer so don't show warning msg
	
	GetElement("UpdateNotification1_TimerMsg").className = "ShowUpdateTIME";

	if (TimeLeft <=1){
		ShowUpdateMsg();
		return;
	}


	if (TimeLeft > 1){DisplayTimeToUpdate();}
	
	timeOn = setTimeout("TimerDecrement()",1000);

}


function ShowUpdateMsg(){
	var tTime = GetElement("UpdateNotification1_TimerMsg");
	var msg
	
	msg = '<b>NOTICE: We are currently updating the site.</b><br><br>' +
	   'While this notice is displayed, we recommend that you do not purchase items from the store, register for programs, administer or take any tests.<br>Refresh your browser on occasion and this notice will be removed when the site update is complete. Thank you for your patience.'

	tTime.innerHTML =  msg;
}

function TimerDecrement(){
	
	if (TimeLeft==''){return;}
	
	TimeLeft --	//decrement total seconds left
	
	if (TimeLeft <= 1){
		ShowUpdateMsg();
		return;	
	}
	
	if (TimeLeft > 1){		
		DisplayTimeToUpdate();
	}
	
	timeOn = setTimeout("TimerDecrement()",1000);
}

function DisplayTimeToUpdate(){
	var tTime = GetElement("UpdateNotification1_TimerMsg");
	var secs = TimeLeft;
	var msg;

	// CONVERT SECONDS TO MINUTES AND SECONDS
    var mins = Math.floor ( secs / 60 );
    secs -= mins * 60;

    // DISPLAY THE FINAL OUTPUT msg STRING       
    
    msg = '<b>We will be performing a site update in about <font color=red>' + pad ( mins ) + "m : " + pad ( secs ) + 's</font>.' +
		'</b><br><br>You may continue browsing the site, howevever if you are registering, ' +
		'purchasing items, taking or administering a test, please finish up before the timer expires. ' +
		'We appologize for any inconvenience.';
    
    tTime.innerHTML =  msg;
}



// THIS FUNCTION INSERTS A LEADING ZERO (IF NECESSARY) TO PROVIDE UNIFORM OUTPUT
function pad ( num )
{
    return ( ( num > 9 ) ? num : "0" + num );
}