function timer(){
var obj=document.getElementById('timer');
var regexp = /(\d+)/i;
var RealTimer = regexp.exec(obj.innerHTML)[0];
RealTimer=RealTimer - 1;
if (RealTimer<0) RealTimer=0;
obj.innerHTML =RealTimer;
if (RealTimer==0) {
alert('time=0');
}
else { setTimeout(timer,1000); }
}
setTimeout(timer,1000);