Написал я вот такой скрипт, но где-то есть ошибка...
Помогите, пожалуйста, исправить её...
Заранее спасибо)
<html>
<head>
<script LANQUAGE="Javascript">
var eventstr = "Это конец халявы!"; //Эта строка выводиться по окончанию отсчета
var montharray=new Array("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec");
function startTime()
{
var now=new Date();
var study=new Date("September 1, 2011 08:00:00");
var hours=now.getHours();
var mins=now.getMinutes();
var secs=now.getSeconds();
var day=now.getDate();
var month=now.getMonth();
var year=now.getFullYear();
hours=checkTime(hours);
mins=checkTime(mins);
secs=checkTime(secs);
day=checkTime(day);
month=checkTime(month+1);
document.getElementById('time').innerHTML=day+"/"+month+"/"+year+" "+hours+":"+mins+":"+secs;
t=setTimeout('startTime()',1);
var futurehours=study.getHours();
var futuremins=study.getMinutes();
var futuresecs=study.getSeconds();
var futureday=study.getDate();
var futuremonth=study.getMonth()+1;
var futureyear=study.getYear();
var today=montharray[month]+" "+day+", "+year+" "+hours+":"+mins+":"+secs;
future=montharray[futuremonth-1]+" "+futureday+", "+futureyear+" "+futurehours+":"+futuremins+":"+futuresecs;
dd=Date.parse(future)-Date.parse(today);
ddays=Math.floor(dd/(24*60*60*1000)*1);
dhours=Math.floor(dd%(24*60*60*1000)/(60*60*1000)*1);
dmins=Math.floor(dd%(24*60*60*1000)%(60*60*1000)/(60*1000)*1);
dsecs=Math.floor(dd%(24*60*60*1000)%(60*60*1000)%(60*1000)/1000*1);
if (ddays<=0&&dhours<=0&&dmins<=0&&dsecs<=1){
document.getElementById('time').innerHTML=day+"/"+month+"/"+year+" "+hours+":"+mins+":"+secs+"<br>"+eventstr;
t=setTimeout('startTime()',1);
return
}
else {
var lastchar = ""+dsec;
lastchar = lastchar.substring(lastchar.length-1,lastchar.length);
var dsecstr = "секунд";
if (lastchar=="1") { dsecstr = "секунда"; }
if ((lastchar=="2")||(lastchar=="3")||(lastchar=="4")) { dsecstr = "секунды"; }
lastchar = ""+dmin;
lastchar = lastchar.substring(lastchar.length-1,lastchar.length);
var dminstr = "минут";
if (lastchar=="1") { dminstr = "минута"; }
if ((lastchar=="2")||(lastchar=="3")||(lastchar=="4")) { dminstr = "минуты"; }
lastchar = ""+dhour;
lastchar = lastchar.substring(lastchar.length-1,lastchar.length);
var dhourstr = "часов";
if (lastchar=="1") { dhourstr = "час"; }
if ((lastchar=="2")||(lastchar=="3")||(lastchar=="4")) { dhourstr = "часа"; }
lastchar = ""+dday;
lastchar = lastchar.substring(lastchar.length-1,lastchar.length);
var ddaystr = "дней";
if (lastchar=="1") { ddaystr = "день"; }
if ((lastchar=="2")||(lastchar=="3")||(lastchar=="4")) { ddaystr = "дня"; }
document.getElementById('time').innerHTML=day+"/"+month+"/"+year+" "+hours+":"+mins+":"+secs+"<br>"+"Осталось: <br>"+ddays+" "+ddaystr+", "+dhours+" "+dhourstr+", "+dmins+" "+dminstr+" и "+dsecs+" "+dsecstr;
t=setTimeout('startTime()',1);
}
}
<!---->
function checkTime(i)
{
if (i<=9)
{
i="0" + i;
}
return i;
}
</script>
</head>
<body onload="startTime()">
<div id="time"></div>
</body>
</html>