Flexible Javascript timer management