//-----------------------------------------------------------------
// Juan Carlos Hernandez
// Jan 2000
// Timer Object
// 	- creates global variable called clock to be used to execute event driven code.
//	- REQUIRES MODIFICATION OF "TICKING" SUBROUTINE TO CUSTOMIZE FOR DIFFERENT PURPOSES
//-----------------------------------------------------------------


//----------------------------------------------------------------
//	setMax method - sets the max iterations for clock
//----------------------------------------------------------------

function setMax(nValue)
 {	this.nMax = nValue;	}

//----------------------------------------------------------------
//	startTimer method - starts the timer
//----------------------------------------------------------------

function startTimer()	{
	this.isMouseOver = false;
	this.nTime = 0;
	this.timerRunning = true;
	ticking();
}

//----------------------------------------------------------------
//	stopTimer method- stops the timer
//----------------------------------------------------------------

function stopTimer()	{
	this.isMouseOver = true;
	this.timerRunning = false;
}

//----------------------------------------------------------------
// ticking subroutine - recursive sub that counts to max value and then returns 
//----------------------------------------------------------------

function ticking()	{
 if(clock.nTime >= clock.nMax && clock.isMouseOver == false) 	{
		hideallMenus(0);
		return;
	}
	if(clock.timerRunning)	{
		clock.nTime++;
		setTimeout('ticking()',1);
	}
}


//----------------------------------------------------------------
//	constructor
//----------------------------------------------------------------
function Timer()
{
	this.isMouseOver = false;
	this.nTime = 0;
	this.timerRunning = false;
	this.nMax = 25;
	
	this.setMax = setMax;
	this.start = startTimer;
	this.stop = stopTimer;
}



//--------------------------------------------------------------
// instantiation of global object
//---------------------------------------------------------------
var clock = new Timer();


