var secs
var timerID = null
var timerRunning = false
var delay = 1000

function InitializeTimer(nSecs,capa,frm)
{
	eval('document.all.' + capa + '.innerHTML=\'' + nSecs +'\'');
    // Set the length of the timer, in seconds
    secs = nSecs
    StopTheClock()
    StartTheTimer(capa,frm)
}

function StopTheClock()
{
    if(timerRunning)
        clearTimeout(timerID)
    timerRunning = false	
}

function StartTheTimer(capa,frm)
{
    if (secs==0)
    {
        StopTheClock()
		eval('document.' + frm + '.submit();');
    }
    else
    {
        secs = secs - 1
        timerRunning = true
        timerID = self.setTimeout("StartTheTimer('" + capa + "','" + frm + "')", delay)
		eval ('document.all.' + capa + '.innerHTML=' + secs)
    }
}
