/**
timer that displays in the document title
@author bibby <bibby@surfmerchants.com>
@version 05/24/2008
$Id: titleTimer.js,v 1.2 2008/07/31 16:45:58 abibby Exp $
*/
var timer={
	t:1801,
	alarms:{
		'0':"URGENT ! Please submit your form NOW to avoid losing your work. You can continue afterwards."
	},
	start:function()
	{
		timer.intv = setInterval('timer.run()',1000);
		timer.original = document.title;
		delete timer.start;
	},
	stop:function()
	{
		clearInterval(timer.intv);
	},
	run:function()
	{
		timer.decrease().update();
	},
	decrease:function()
	{
		timer.t--;
		return timer;
	},
	update:function()
	{
		if(timer.t<0)
		{
			timer.stop();
			delete timer;
			return;
		}
		
		if(timer.alarms[timer.t])
		{
			setTimeout('alert(timer.alarms[timer.t])');
		}
		
		document.title = timer.original + '  (' + timer.parseTime()+')';
	},
	parseTime:function()
	{
		return (Math.floor(timer.t/60))+':'+ timer.pad(Math.floor(timer.t%60));
	},
	pad:function(n)
	{
		return n.toString().length==1? '0'+n : n ;
	}
};
