I have trouble with timer in button click. When i click button startpause() method is called there i set start timer and stop timer. It works fine when I click button normally(one click after sometime another click) but when I click the button again and again speedly the timer starts to jump with 2-3 secs. Seems like more than one timer is running.. Anyone have any idea....?? here time is my timer method
function startpause() {
    if(FLAG_CLICK) {
        setTimeout(tim,1000);               
        FLAG_CLICK = false;
    }
    else {
        clearTimeout(ti);
        FLAG_CLICK = true;
    }
}
function tim() { 
    time.innerHTML = t;
    t = t + 1;      
    ti= setTimeout("tim()", 1000);
}
 
     
     
    