<script type="text/javascript">
var oToday = new Date();
function getDaysLeft(oDeadLineDate, oToday){
return oDeadLineDate > oToday ? Math.ceil((oDeadLineDate - oToday) / (1000 * 60 * 60 * 24)) : null;
}
function MkDaysLeft(sDeadLineDate, sDeadLineText){
var sTime = sDeadLineDate + " " + oToday.getHours() + ":" + oToday.getMinutes() + ":" + oToday.getSeconds();
var oDeadLineDate = new Date(sTime);
var nDaysLeft = getDaysLeft(oDeadLineDate, oToday);
if (nDaysLeft){
var sDaysLeft = String(nDaysLeft);
var sDaysText = "дней";
var nDaysLeftLength = sDaysLeft.length;
if (sDaysLeft.charAt(nDaysLeftLength - 2) != "1"){
if (sDaysLeft.charAt(nDaysLeftLength - 1) == "2" || sDaysLeft.charAt(nDaysLeftLength - 1) == "3" || sDaysLeft.charAt(nDaysLeftLength - 1) == "4") sDaysText = "дня";
else if (sDaysLeft.charAt(nDaysLeftLength - 1) == "1") sDaysText = "день";
}
var sLeftText = sDaysText == "день" ? "остался" : "осталось";
document.write(sDeadLineText + " " + sLeftText + " " + nDaysLeft + " " + sDaysText + ".");
}else document.write("С новым годом! С новым счастьем!");
}
MkDaysLeft("January 01, 2008", "До нового года");
//-->
</script