$(document).ready(function(){
function timer(y, m, d, H, i, s){
var finishday = new Date(y, m, d, H, i, s);
endTS = finishday.getTime();
var intervalid = setInterval(function(){
var now = new Date();
var totalRemains = (endTS - now.getTime());
if (totalRemains>1){
var RemainsSec=(parseInt(totalRemains/1000));
var RemainsFullDays=(parseInt(RemainsSec/(24*60*60)));
var secInLastDay=RemainsSec-RemainsFullDays*24*3600;
var RemainsFullHours=(parseInt(secInLastDay/3600));
if (RemainsFullHours<10){RemainsFullHours="0"+RemainsFullHours};
var secInLastHour=secInLastDay-RemainsFullHours*3600;
var RemainsMinutes=(parseInt(secInLastHour/60));
if (RemainsMinutes<10){RemainsMinutes="0"+RemainsMinutes};
var lastSec=secInLastHour-RemainsMinutes*60;
if (lastSec<10){lastSec="0"+lastSec};
$('.timer').html((RemainsFullDays ? "<span>"+RemainsFullDays+"дн.</span> " :"")+RemainsFullHours+":"+RemainsMinutes+":"+lastSec);
}
else { clearInterval(intervalid); timer(y, m, d, H, (i+1 > 59 ? 0 : i+1), s); }
},1000);
}
timer(2013, 0, 1, 0, 0, 0);
});