$(document).ready(function() { var $counter; initCounter($('.flaechenuhr .ziffern')); function initCounter(_counter) { $counter = _counter; //var now = new Date(); //new Date(2008, 1, 2, 0, 0, 0); // var nullpunkt = new Date(2011, 3, 1, 0, 0, 0); var now = new Date(2012,1,23,0,18,00); //start 30 millionen quadratkilometer var start = 383880000 + Math.round(((now-nullpunkt)/1000)*0.8449) $counter.data('count',start); setCounter((String(start))); } //testetst function addNumber() { var count = Math.round(($counter.data('count'))+1); $counter.data('count',count); setCounter(String(count)); } function setCounter(number){ $.each($counter, function(e, el) { var number_array= number.split(''), _length = number_array.length, zero = 9 - _length, pos = 0; $.each($(el).find('li span'), function(e) { /* if (zero == 0) { $(this).attr('class', 'n'+number_array[pos]); pos++; } else { $(this).attr('class', 'n0'); zero--; } */ if (zero == 0) { if(pos==2 || pos==5) { $(this).attr('class', 'n'+number_array[pos]+' abstand'); } else { $(this).attr('class', 'n'+number_array[pos]); } pos++; } else { $(this).attr('class', 'n0'); zero--; } }); }); setTimeout(addNumber,1183); } });