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") document.getElementById("day").className = "days_3";
      else if (sDaysLeft.charAt(nDaysLeftLength - 1) == "1") document.getElementById("day").className = "days_1";
    }
    var sLeftText = sDaysText == "день" ? "остался" : "осталось";
  // document.write(sDeadLineText + " " + sLeftText + " " + sTime + " " + nDaysLeft + " " + sDaysText + ".");
  
var d_one = (sDaysLeft + '').charAt ((sDaysLeft + '').length - 1); 
var d_two = (sDaysLeft + '').charAt ((sDaysLeft + '').length - 2); 
var d_tre = (sDaysLeft + '').charAt ((sDaysLeft + '').length - 3); 

if  (nDaysLeft > 99 ){
document.getElementById("d3").className = "num_"+d_one;
document.getElementById("d2").className = "num_"+d_two;
document.getElementById("d1").className = "num_"+d_tre;
}
if  (nDaysLeft < 99 && nDaysLeft > 9){
document.getElementById("d3").className = "num_"+d_one;
document.getElementById("d2").className = "num_"+d_two;
}
if  (nDaysLeft < 10 ){
document.getElementById("d3").className = "num_"+d_one;
}
   
  }else document.getElementById("d1").className = "num_0";
}

MkDaysLeft("jun 11, 2010", "");
	    


