js smart timer with cookies