var secs
var timerID = null
var timerRunning = false                                                                                                                                      
var delay = 1000
var timp=0

function InitializeTimer(){
    secs = timp;
    StopTheClock();
    if(timp>1) StartTheTimer();
}

function StopTheClock(){
  if(timerRunning) clearTimeout(timerID); 
  timerRunning = false;
}           
                 
function showalertbox(){
    document.getElementById('popupbox').style.visibility="visible";
}
				 
function StartTheTimer(){
  if (secs==0){
    StopTheClock();
	showalertbox();
	setTimeout("document.form.submit()",3000);
  }else{
    self.status = secs;
    secs = secs - 1;
    document.frm.clock.value = secs;
    timerRunning = true;
    timerID = self.setTimeout("StartTheTimer()", delay);
  }
}
                                                                                                                                                                                                                                                          
