// JavaScript Document

<!--
// theForm global var
function InitializeTimer(tm,ts)
{
    // Set the length of the timer, in seconds
    mins = tm
    secs = ts
    StopTheClock()
    //alert("init "+theForm)
    StartTheTimer()
}

function StopTheClock()
{
    if(timerRunning)
        clearTimeout(timerID)
    timerRunning = false
}

function StartTheTimer()
{
    document.getElementById("timer").innerHTML = mins + ":" + secs
    if (secs==0 && mins==0)
    {
        StopTheClock()
        // Here's where you put something useful that's
        // supposed to happen after the allotted time.
        // For example, you could display a message:
        alert("Your time is up !\n \nYou have completed your time for this test and it will be automatically submitted for scoring.")
        //alert(document.forms[theForm].name)
        document.forms[theForm].timeover.value = "yes"
        passTimer()  // exists in ask_questions.jsp
        document.forms[theForm].submit()
    }
    else
    {
        //self.status = secs
        if (secs==0) {
            mins = mins-1
            secs=60
        }
        secs = secs - 1
		
        timerRunning = true
        timerID = self.setTimeout("StartTheTimer()", delay)
    }
}
//-->
